Repository navigation
refactor(cli): web-standard (Request) => Response runtime core; Node listener becomes an adapter (deploy-anywhere B1) - #373
Merged
Conversation
…ror teardown, AP disconnect parity, activeRequests leak, host/status/cookie edge cases Co-Authored-By: Claude Fable 5 <[email protected]>
…r under full-suite load
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
This was referenced Sep 17, 2026
blove
added a commit
that referenced
this pull request
Sep 17, 2026
…00 (#711) `statusResponse` built every middleware reject with `Response.json(body)`, which throws when `body` is `undefined`. The documented body-omitted form of `reject(status)` therefore answered 500 "Unexpected runtime server failure" instead of the 401 or 403 the app asked for, on the AG-UI and both Agent Protocol run endpoints. A body-less reject now sends an empty payload under the JSON content-type at the requested status. On the Node targets, body-less replies are now framed with `Content-Length: 0` rather than `Transfer-Encoding: chunked`, restoring the pre-`fetch`-core framing and extending the adapter's existing content-length rule for JSON to empty payloads. The statuses that forbid a body (204, 205, 304) keep Node's own suppression. Regressed in #373. A separate live instance of the same bug class, on the route-output path, is filed as #714. Merged with admin: the required `validate` check is green, and the advisory `review` check failed only because the org's Anthropic credit balance is exhausted. An independent review stood in for it and caught the chunked-framing defect above.
This branch was successfully deployed
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.
Web-standard request core (deploy-anywhere B1)
Dawn's served runtime was welded to
node:http— handlers typed(IncomingMessage, ServerResponse) => void, responses written through Node sinks. That blocks the edge build targets (Cloudflare Workers / Vercel / Hono) of the deploy-anywhere epic, whose runtimes speak Web-standardfetch.This extracts a transport-agnostic
createRuntimeFetchHandler(options) → (request: Request) => Promise<Response>core (exported from@dawn-ai/cli/runtime) and reimplements the Node listener as a thin adapter over it. Zero behavior change —dawn dev,dawn start, andserveRuntimekeep their exact signatures and wire behavior.What changed
runtime-fetch-handler.ts): the boot assembly, route table, shutdown state, and drain logic, returning WebResponses. JSON viaResponse.json; the three SSE sites (AP stream, resume, AG-UI) viaReadableStream— the pure string encoders (toSseEvent,encodeAgUiSse) untouched. In-flight accounting transfers to the stream's completion paths soclose()never releases sandboxes mid-stream, with a bounded drain deadline.node-web-adapter.ts):IncomingMessage → Request(socket close abortsrequest.signal; streaming body withduplex: "half") andResponse → ServerResponse(JSON keepsContent-Lengthframing; SSE streams incrementally;getSetCookiepreserved; stream errors tear the socket down rather than framing truncation as success).@dawn-ai/testing):injectAgentProtocoldrives the fetch core directly;light-my-requestremoved from the dependency tree.The safety invariant, held
Every pre-existing test passes unchanged (445-test baseline → 467 → 472 with the new coverage; zero edits to existing tests). An adversarial review of the flip — reproducing findings over raw sockets — caught 7 wire-parity regressions the suite couldn't see, all fixed with regression tests:
JSON responses silently switching to chunked framing; AG-UI mid-stream errors terminating as clean success; two
activeRequestsleak paths that could hangclose()and leak sandboxes; empty/bogusHostkilling the connection; middleware rejects with 204/304 becoming 500s; repeatedset-cookiedropped for middleware; and AP stream/resume gaining abort-on-disconnect the old server never had (reverted to parity; the semantic question is a deliberate follow-up).Verification
verify:harness:runtime(real dev-server parity) +verify:harness:smoke.Changeset: patch (
@dawn-ai/cli,@dawn-ai/testing). Next in the epic: B2 (build-time static wiring — kill per-requestreaddir+ tsx-loader dependence), then B3 (the Workers/Vercel/Hono targets with per-target capability gating).🤖 Generated with Claude Code