Skip to content

Print the server's URL when serving - #8595

Merged
ry merged 4 commits into
mainfrom
ry/serve-url
Nov 18, 2026
Merged

ry merged 4 commits into
mainfrom
ry/serve-url

Conversation

@ry

@ry ry commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

workerd serve printed 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:

$ workerd serve wrangler.json
Listening on http://localhost:8787

It stays quiet with --control-fd, which Miniflare and other tools read instead, and for test and bench.

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.
@ry
ry requested review from a team as code owners November 18, 2026 06:37
@ry
ry requested a review from jasnell November 18, 2026 06:37

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/workerd/server/server/run.rs Resolved
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.

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::new drops announce under --control-fd. test, bench and the in-process server never set it.
  • The line is printed in the same loop as the control listen events, after the config check.
  • listen::url shows a wildcard host as localhost and 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.rs covers these cases.

📝 Documentation: ✅ LGTM

The doc comments on RunOptions::announce, Control and listen::url match the behaviour.


Reviewed commit: a4dab540

ry added 2 commits November 18, 2026 07:54
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.

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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_serve sets announce before report is shadowed, so the closure calls the CLI's report(). Under structured logging the line comes out as JSON. The earlier structured-logging concern stays fixed. test, bench and the in-process server never set announce.
  • run.rs: Control::listen prints 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 control listen events. The debug port passes None, so it is never announced.
  • listen/mod.rs: url/url_of give a URL only for http and https sockets. They show * and 0.0.0.0 as localhost. They return nothing for empty, loopback and unix: addresses.
  • mod-test.rs: The tests cover the wildcard, IPv6, loopback and Unix cases of url_of.

📝 Documentation: ✅ LGTM

The doc comments on Announce, RunOptions::announce, Control and listen::url match the behaviour at this commit.


Reviewed commit: 1b95329b

@ry
ry merged commit 50742c3 into main Nov 18, 2026
24 checks passed
@ry
ry deleted the ry/serve-url branch November 18, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants