You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The gateway passes a worker's framing headers through to the caller #546
The gateway copies every header from a worker's relay head onto the response it sends the caller (src/gateway/relay.ts, around line 252). Framing headers such as content-length and transfer-encoding from a worker can reach the caller.
What should happen
Both sides drop hop-by-hop and framing headers, as the spec of #514 says; the gateway sets its own framing for the response it streams.
Confirmed: a defect on main, reproduced by a failing gateway unit test on bug/546-repro.
Reproduction
Branch bug/546-repro (commit de704f9d, test only), src/gateway/relay.test.ts:
drops every hop-by-hop and framing header of a worker's relay head, in any case, and keeps an ordinary header, on the response it hands the caller
pnpm exec vitest run --project unit src/gateway/relay.test.ts
The test drives GatewayRelay over the scripted connection with a relay-head push carrying all nine framing/hop-by-hop names the contract lists (three in mixed case, the case edge) plus x-kept, and asserts the caller's response headers equal exactly [["x-kept","yes"]]. It fails on that deep-equality assertion with all nine present:
The unit level is where this can fail for the right reason: the existing e2e (relay-gateway.e2e.test.ts:650) shows content-length gone only because the worker strips it in #respond; a same-version worker's head never carries a framing header, so nothing above the gateway's own head handling can force one. Verified as reading the code plus Node's Headers (v24): it accepts all nine names on a Response — none is guarded — so a head that carries them hands them to the caller.
Root cause
Defect.src/gateway/relay.ts:207 — #onHead copies every [name, value] pair of the worker's head straight onto the Response: for (const [name, value] of headers) responseHeaders.append(name, value). relayHeadersSchema bounds the shape of a header, not which header arrives, and the wire is a claim, not a fact (safety rule 10), so the gateway must apply #514's own rule — "both sides drop the framing and hop-by-hop headers, which the relay re-creates" — when it parses the head. It does not. The other two header paths of the relay do drop them through relayHeaderPairs (request side, relay.ts:136; worker's response side, src/daemon/relay.ts:253); the gateway's head handling is the one path missing the drop. Present since the relay landed (#528).
Simplest fix
In #onHead's append loop, skip pairs the contract already knows: if (isRelayFramingHeader(name)) continue; (src/contract/relay.ts:47, exported, case-insensitive, the one place the nine names are listed). No wire or protocol change. Verified locally: with that one guard the new test passes and all 36 tests in the file pass.
Alternatives rejected
Drop them in src/daemon/relay.ts#respond instead — already done there; the missing drop is the gateway not trusting wire input, which the worker cannot fix for it.
Delete framing names from responseHeaders after the loop — same size, but splits the drop across two mechanisms when the predicate exists to be used at the boundary.
Refuse framing names in relayHeadersSchema — a contract-shape change (protocol bump) that kills the whole relay over one stray header instead of ignoring it.
src/stream reads only its own simlock-stream-* headers off a relayed response; confirm nothing else in it or the agent-device front depends on a dropped name.
Keep #onHead's existing Headers-refusal path (#invalid) working: the skip must not turn a refused value into a silently dropped one.
Activity
test: reproduce #546 — the gateway passes a worker's framing headers …
V3RON commentedon Oct 16, 2026
Confirmed: a defect on
main, reproduced by a failing gateway unit test onbug/546-repro.Reproduction
Branch
bug/546-repro(commitde704f9d, test only),src/gateway/relay.test.ts:pnpm exec vitest run --project unit src/gateway/relay.test.tsThe test drives
GatewayRelayover the scripted connection with arelay-headpush carrying all nine framing/hop-by-hop names the contract lists (three in mixed case, the case edge) plusx-kept, and asserts the caller's response headers equal exactly[["x-kept","yes"]]. It fails on that deep-equality assertion with all nine present:The unit level is where this can fail for the right reason: the existing e2e (
relay-gateway.e2e.test.ts:650) showscontent-lengthgone only because the worker strips it in#respond; a same-version worker's head never carries a framing header, so nothing above the gateway's own head handling can force one. Verified as reading the code plus Node'sHeaders(v24): it accepts all nine names on aResponse— none is guarded — so a head that carries them hands them to the caller.Root cause
Defect.
src/gateway/relay.ts:207—#onHeadcopies every[name, value]pair of the worker's head straight onto theResponse:for (const [name, value] of headers) responseHeaders.append(name, value).relayHeadersSchemabounds the shape of a header, not which header arrives, and the wire is a claim, not a fact (safety rule 10), so the gateway must apply #514's own rule — "both sides drop the framing and hop-by-hop headers, which the relay re-creates" — when it parses the head. It does not. The other two header paths of the relay do drop them throughrelayHeaderPairs(request side,relay.ts:136; worker's response side,src/daemon/relay.ts:253); the gateway's head handling is the one path missing the drop. Present since the relay landed (#528).Simplest fix
In
#onHead's append loop, skip pairs the contract already knows:if (isRelayFramingHeader(name)) continue;(src/contract/relay.ts:47, exported, case-insensitive, the one place the nine names are listed). No wire or protocol change. Verified locally: with that one guard the new test passes and all 36 tests in the file pass.Alternatives rejected
src/daemon/relay.ts#respondinstead — already done there; the missing drop is the gateway not trusting wire input, which the worker cannot fix for it.responseHeadersafter the loop — same size, but splits the drop across two mechanisms when the predicate exists to be used at the boundary.relayHeadersSchema— a contract-shape change (protocol bump) that kills the whole relay over one stray header instead of ignoring it.Risk
content-length(chunked framing) — that is feat(fleet): a gateway relays an HTTP exchange to a worker module over the uplink #514's intent, but checkgateway-front.test.ts"downloads over 2 GiB" (the 413 cap is enforced worker-side inhost.ts, so it should stay green).src/streamreads only its ownsimlock-stream-*headers off a relayed response; confirm nothing else in it or the agent-device front depends on a dropped name.#onHead's existingHeaders-refusal path (#invalid) working: the skip must not turn a refused value into a silently dropped one.Written by an agent.
fix(gateway): drop a worker's framing headers from the relayed respon…
fix(gateway): write the framing-header comment as plain prose (#546)
fix(gateway): drop a worker's framing headers from a relay head (#643)
V3RON commentedon Oct 16, 2026
Delivery run
Merged: #643 (#546)
Parked: none
Waiting: none
Decided: none
Round 1 of the reviews passed with no findings (spec, code, claims: F0). The gate merged at
8e45a994. No slow-lane check was needed.Written by an agent.