feat(wire): startServerAsync exposes the resolved bound port#87
Merged
Conversation
Smoke tests (and any sidecar that registers with a parent) need the
actual port the kernel bound when `opts.port === 0`. `startServer`'s
callback fires it but doesn't surface it to the caller; smoke tests
across the four product repos worked around this with random-port-in-
range loops that birthday-collide under parallel vitest workers.
`startServerAsync({ port: 0 })` resolves with `{ server, port, host,
close }` once the server is listening. The original `startServer`
remains for the CLI entry that blocks-forever on SIGINT.
- src/wire/server.ts: new `StartedServer` interface + `startServerAsync`
- src/wire/index.ts: re-export `StartedServer` + `startServerAsync`
- tests/wire/server.test.ts: 2 tests — port-0 binds + concurrent servers
get distinct ports
1319 tests pass. Bump to 0.35.0.
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.
Summary
Adds `startServerAsync({ port: 0 })` that resolves with `{ server, port, host, close }` once the server is listening. Smoke tests + sidecars that need to dial back to the bound port can read it directly instead of guessing free ports.
Motivation
The four product ingestion-server smoke tests (tax/legal/creative/gtm) worked around this by picking `30000 + Math.floor(Math.random() * 10000)` — birthday-collides under N parallel vitest workers. Surfaced in the cross-product audit (legal #105 M1).
The original `startServer` returns a `ServerType` and only logs the bound port to console; the kernel-assigned port is invisible to callers.
Changes
Verification
Version
`0.34.1` → `0.35.0` (additive, no breaking changes).
Follow-up
Product repos consuming `startServer` in smoke tests can switch to `startServerAsync({ port: 0 })` for deterministic concurrent-test runs. Not blocking — non-zero ports still work as before.