Repository navigation
fix(plugin-hono-server): a request for port 0 no longer warns that port 0 is in use - #24402
Merged
objectstack-fleet[bot] merged 2 commits intoOct 18, 2026
Merged
Conversation
… a real busy port A request for port 0 that binds port N must print no busy-port line at the CLI's default level or at info; a held non-zero port must still warn, naming the requested and the bound port. Red on this commit: the fix follows. Claude-Session: https://claude.ai/code/session_01SYEJqDL3NXxrJRBVqaMu9T Co-authored-by: Claude <noreply@anthropic.com>
…rt 0 is in use kernel:listening compared the requested port with the bound one and warned whenever they differed. Port 0 asks for a kernel-assigned port, so the two can never match and nothing was in use. The warning now fires only for a non-zero request the adapter's EADDRINUSE walk moved; the started line already names the bound port. The released-port ledger's reason for serve-port-drift-notice.e2e.test.ts quoted that warning as why its negative arm cannot use --port 0. It now states only the arm's subject: a non-zero request, which --port 0 cannot ask. Claude-Session: https://claude.ai/code/session_01SYEJqDL3NXxrJRBVqaMu9T Co-authored-by: Claude <noreply@anthropic.com>
Contributor
📓 Docs Drift CheckNothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 1 changed package(s)), so this run has no opinion about the docs. What this run could not see
Coarse fallback — 9 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
Contributor
Author
席位核对ACCEPT (lane review) ·
Generated by Claude Code |
objectstack-fleet
Bot
deleted the
claude/issue-24387-port-zero-warning
branch
October 18, 2026 22:58
This was referenced Oct 18, 2026
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.
Fixes #24387
Clause-②: no (basis: a log line stops firing for a legal request; nothing accepted or exported moves, and no export, option or type changes)
What changed
HonoServerPlugin'skernel:listeninghook compared the requested port with the bound port and warnedPort 0 is in use, using port N insteadwhenever the two differed. Port0is a legal request for a kernel-assigned port:listen(0)can never bind the number it was given, so nothing was in use. The hook now warns only for a non-zero request that the adapter's EADDRINUSE walk moved (port !== 0 && actualPort !== port). A kernel-assigned boot prints only the existingHTTP server started successfullyinfo line, which already names the bound port. No line is added.packages/plugins/plugin-hono-server/src/hono-plugin.ts: the guard, with a comment saying why.packages/plugins/plugin-hono-server/src/kernel-listening-port-notice.test.ts(new): the card's pins.packages/cli/test/released-port-production-spawn.pin.test.ts: the ledger reason forserve-port-drift-notice.e2e.test.tsquoted this warning as the reason its negative arm cannot use--port 0, and this change makes that clause false. The reason now states only the arm's subject: a boot that binds exactly the non-zero port it asked for, which--port 0cannot ask. The entry and itsdraws: 1are unchanged..changeset/24387-port-zero-busy-warning.md:patchon@objectstack/plugin-hono-server.Text that quotes or relies on the warning (
git grepforin use, using portand foris in useover the tree): the pin ledger reason above, and nothing else. The helper docblock inpackages/cli/test/helpers/serve-process.tsnames the same subject ("a boot that must bind exactly the port it asked for, which--port 0cannot ask") without the warning, and stays true. The boot-noise budget test (serve-boot-diagnostics-noise-budget.e2e.test.ts) pins no informational count, so it needs no change. No doc page quotes the line. The CLI's own drift notice (Port N is in use — serving on M instead.) is a different line inpackages/cli/srcand is not touched.The pins, and why they sit at the plugin
Three cases run the plugin's real
init()/start(), the REAL adapter (a real socket is bound) and the REAL core logger (createLogger, json format) at the levels the CLI runs it at. They read the records the hook writes by kind and count, not by wording:0at the CLI's default kernel level (warn): no record at all;0atinfo: exactly one record, atinfo, whoseportis the bound port;warn: the adapter really moved (bound differs from held), and exactly onewarnrecord names both the requested and the bound port.Why here and not in the CLI's boot-diagnostics tests: this hook is the line's only producer, and the CLI banner only replays what the kernel logger wrote. The CLI test that reads the Boot diagnostics block is a nightly e2e cold start of a scaffolded project, and it deliberately pins no informational count. The plugin test drives the producer through a real socket in milliseconds of test time and runs in every PR's Test Core. No file changed tier: the new file is a plain plugin unit test, and the CLI pin file's edit is one string literal (it ran under
--project unit).Measurement, fix, ablation
"level": "warn", "msg": "Port 0 is in use, using port 36051 instead"atwarn, and the same line beside the started line atinfo.scripts/ablation-replace.mjsin wrap mode, plus atraprestore on EXIT INT TERM against the absolute path): anchorif (port !== 0 && actualPort !== port) {hit 1 time, 1 -> 0; replacementif (actualPort !== port) {0 -> 1; blob 70d649417902 -> c5a5b2f078ce. Independent on-disk count during the mutation: guard 0, reverted 1. Pin result: cases 1 and 2 red (Port 0 is in use, using port 44497 instead), case 3 green. Restore: blob after restore 70d649417902 == HEAD blob 70d649417902,git diff HEADempty,git status --porcelainempty. The pin imports./hono-pluginby relative path fromsrc/, so nodist/is on its path and the dist preflight does not apply.os serve objectstack.config.ts --port 0againstexport default {};, plugindist/rebuilt from b2509f8): default level, banner reached, 0 busy-port lines, no Boot diagnostics block,API: http://localhost:42961/;--log-level info, banner reached, 0 busy-port lines, oneHTTP server started successfully {"port":38147,...}line matchingAPI: http://localhost:38147/. Both servers stopped by recorded PID.Local verification (all at b2509f8)
pnpm --filter '@objectstack/plugin-hono-server^...' build: exit 0.pnpm --filter @objectstack/plugin-hono-server test: 32 files, 393 tests passed.pnpm --filter @objectstack/plugin-hono-server typecheck: exit 0 (tsc --listFiles -p tsconfig.test.jsonlists the new test file).pnpm --filter @objectstack/cli exec vitest run --project unit test/released-port-production-spawn.pin.test.ts test/vitest-tiers-partition.test.ts: 2 files, 26 tests passed.pnpm --filter @objectstack/cli typecheck: exit 0.eslint --no-inline-configover the three changed TypeScript files: exit 0, no output.node scripts/pm/dispatch-gates.mjs --commands: 66 derived commands, each run with its exit code captured before any pipe, plus the 11 declared-wide families: all exit 0.check:dual-build-cjs-loadsandcheck:lean-entry-closurefirst exited 3 (PREREQUISITE NOT MET, no workspacedist/); aftercheck:type-check-debt's own full build they were re-run and exited 0.--ran: 66 derived, 66 run, 0 NOT-MEASURED, 0 UNRUN. The four roster gates whose rosters sit beside these paths (check-changeset-fixed,check:authz-resolver,check:error-code-casing,check:filter-alias-parity): exit 0.test:repoare left to CI's Test Core. The CLI diff is one string literal in a unit-tier pin, andpackages/cli/srcis untouched.Acceptance notes
hono-plugin.test.ts'sshould start without errorscase comments "Plugin should register kernel:ready hook to start listening", but the socket opens onkernel:listening. A stale comment, noted and not filed.HonoServerPlugin.destroy()calls the adapter's asyncclose()without awaiting it. Noted, not filed: nothing measured here depends on it.Generated by Claude Code