Repository navigation
server: add workerd check, and suggest the closest service name - #8083
Draft
bartlomieju wants to merge 2 commits into
Draft
bartlomieju wants to merge 2 commits into
bartlomieju wants to merge 2 commits into
Conversation
A designator naming a service that is not defined now ends its error with a hint naming the closest defined service, when one is within a small edit distance (case-insensitive Levenshtein, at most a third of the name's length and at least 2): Socket "http" refers to a service "mainn", but no such service is defined. Did you mean "main"? This covers every lookup through lookup_service and lookup_actor_class: sockets, bindings, globalOutbound, cacheApiOutbound and tails.
`workerd check <config-file>` loads a config the way `serve` does, .capnp or wrangler.json(c), builds every service and compiles every Worker, and resolves every socket's service, but binds no socket and joins no cluster. It reports every error rather than only the first, then either "N config errors found." with exit status 1, or "Config OK: N services, N sockets.". --directory-path and --external-addr are checked against the config as `serve` checks them. A socket without an address is a warning, since `serve` takes it from --socket-addr or --socket-fd. --watch and --inspector-addr are usage errors rather than silently ignored. The socket designator lookup `start` did inline moves into socket_channel, which `check` shares. A shell test runs the binary on a valid config, one with three errors, an unmatched override and a wrangler.jsonc.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8083 +/- ##
==========================================
- Coverage 68.18% 68.15% -0.03%
==========================================
Files 712 712
Lines 185743 185881 +138
Branches 29255 29255
==========================================
+ Hits 126645 126685 +40
- Misses 42019 42118 +99
+ Partials 17079 17078 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #8065, rebuilt on top of #8051.
workerd check <config-file>loads a config the wayservedoes,.capnporwrangler.json(c), builds every service and compiles every Worker, and resolves every socket's service. It binds no socket and joins no cluster. Every error is reported, not only the first, followed by a summary. The exit status is 1 if there was any error.Two commits:
lookup_serviceandlookup_actor_class(sockets, bindings,globalOutbound,cacheApiOutbound, tails) appendsDid you mean "x"?. The suggestion is made when a defined service is within a small, case-insensitive edit distance.--directory-pathand--external-addrare checked against the config, asservechecks them.servecan take the address from--socket-addror--socket-fd.--watchand--inspector-addrare usage errors rather than being silently ignored.start()did inline is nowsocket_channel(), which both commands use.Tests: unit tests for the hint, and a new shell test,
src/workerd/server/tests/check. It runs the binary on a valid config, on one with three errors, with an override that matches nothing, on awrangler.jsonc, and with--watch.