Repository navigation
Print the server's URL when serving - #8595
Conversation
workerd serve printed nothing at startup, so a person could not tell whether it was up or where. It now prints "Listening on <url>" to stderr once per socket, with a wildcard host shown as localhost. It stays quiet under --control-fd, which tools such as Miniflare read instead, and for test and bench.
There was a problem hiding this comment.
Superseded by the review of
a4dab540.
This review, of bdb25688
💬 Approved with comments — A small, well-scoped change. One WARNING: the new stderr line skips the CLI's structured-logging switch, so it puts plain text into JSON stderr output.
Findings: 1 warning (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #8595.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] The "Listening on" line uses a bare `eprintln!`, so under structured logging it writes plain text into JSON-lines stderr.
- **File:** src/workerd/server/server/run.rs:107
📋 Code Quality: ⚠️ 1 warning
The new "Listening on" line skips the structured-logging switch that the CLI's other stderr messages go through.
Recommendation: 📝 Minor Comments
- [WARNING] The "Listening on" line uses a bare
eprintln!, so under structured logging it writes plain text into JSON-lines stderr. (src/workerd/server/server/run.rs:107)
View full review
Structured logging is bypassed (src/workerd/server/server/run.rs:107)
Control::listen prints the line with a bare eprintln!. Everywhere else, the CLI's own stderr messages go through report in src/workerd/server/server/entry.rs:168-174. Under structured logging, report writes each message as a JSON line through ffi::json_log_to_stderr.
So workerd serve with structured logging on and no --control-fd will now put one plain-text line into a stderr stream that is otherwise JSON lines. A log collector that parses those lines will choke on it. To fix this, pass the structured flag down to start(), for example through RunOptions, and send the line through report(structured, Severity::Info, ...). Alternatively, skip the line when logging is structured.
✅ All other checks passed
📝 Documentation: ✅ LGTM
The doc comments on Control and listen::url correctly describe when the URL is printed and which sockets are skipped.
Reviewed commit: bdb25688
The line skipped structured logging, so it put plain text among the JSON lines on stderr, and it printed for every run of the server, the in-process one the tests use included, with loopback sockets as http://loopback:0. serve now passes RunOptions::announce, which writes through report(), and loopback addresses get no URL.
There was a problem hiding this comment.
Superseded by the review of
1b95329b.
This review, of a4dab540
✅ Approved — The earlier structured-logging warning is fixed: the line now goes through report(), and only serve prints it. No new issues were found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
📋 Code Quality: ✅ LGTM
Earlier finding, fixed. server_serve now sets options.announce to a closure that calls report(structured, Severity::Info, line) (src/workerd/server/server/entry.rs:247-249). The "Listening on" line therefore goes through the same path as the CLI's other stderr messages.
Checked:
Control::newdropsannounceunder--control-fd.test,benchand the in-process server never set it.- The line is printed in the same loop as the control
listenevents, after the config check. listen::urlshows a wildcard host aslocalhostand puts a bare IPv6 address in brackets. It returns nothing for Unix, loopback and empty addresses, and the debug port passes no URL.mod-test.rscovers these cases.
📝 Documentation: ✅ LGTM
The doc comments on RunOptions::announce, Control and listen::url match the behaviour.
Reviewed commit: a4dab540
Only HTTP and HTTPS sockets get a URL, only * and 0.0.0.0 are shown as localhost, and Control prints it in listen(), unchanged otherwise.
There was a problem hiding this comment.
✅ Approved — The narrowed URL logic in listen/mod.rs and the reworked Control::listen in run.rs behave as the description says. No issues found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
📋 Code Quality: ✅ LGTM
No issues found in the files that changed since the last review.
entry.rs:server_servesetsannouncebeforereportis shadowed, so the closure calls the CLI'sreport(). Under structured logging the line comes out as JSON. The earlier structured-logging concern stays fixed.test,benchand the in-process server never setannounce.run.rs:Control::listenprints the line only when there is no control channel, an announce callback is set and the socket has a URL. It prints in the same loop as the controllistenevents. The debug port passesNone, so it is never announced.listen/mod.rs:url/url_ofgive a URL only forhttpandhttpssockets. They show*and0.0.0.0aslocalhost. They return nothing for empty,loopbackandunix:addresses.mod-test.rs: The tests cover the wildcard, IPv6, loopback and Unix cases ofurl_of.
📝 Documentation: ✅ LGTM
The doc comments on Announce, RunOptions::announce, Control and listen::url match the behaviour at this commit.
Reviewed commit: 1b95329b
workerd serveprinted nothing at startup, so you couldn't tell whether it was up or where. It now prints one line per HTTP socket to stderr, with a wildcard host shown as localhost:It stays quiet with
--control-fd, which Miniflare and other tools read instead, and fortestandbench.