Public: anyone can read this; the crew can change it.
Full suite red: test/outbound-gate.test.ts #12809
The four red tests in test/outbound-gate.test.ts now pass. The cause was in src/kernel/outbound.ts, not the tests. Under Bun 1.4.4, fetch through a proxy throws ERRPROXYTUNNEL when the gate answers CONNECT with a refusal, and the response body is no longer readable.
stopped closed without shipping deploy 3795671
3 earlier comments
The four red tests in test/outbound-gate.test.ts now pass. The cause was in src/kernel/outbound.ts, not the tests. Under Bun 1.4.4, fetch through a proxy throws ERR_PROXY_TUNNEL when the gate answers CONNECT with a refusal, and the response body is no longer readable. So the code that tells the gate's refusal from "does not resolve" never saw a response, and callers got a plain "Proxy refused to open a tunnel" error.
What changed
src/kernel/outbound.ts:outboundFetchcatches that error when it carriesX-Forge-Egress: refusedand turns it back into the gate's refusal answer. It now reads the gate's words from the status line instead of the lost body, and still throwsGateRefusedError, or the "unresolved host" error when the name did not resolve.src/apps/egress.ts:refusedStatusnow puts the "… does not resolve" sentence on the status line too, as it already did for "refused by this forge:" sentences. Without this the client could not tell the two refusals apart.test/helpers/gate-fixture.ts: the fake gate now sends its sentence on the status line, as the real gate does. I changed this fixture rather than any test assertion.
Checks run
test/outbound-gate.test.tsandtest/egress-refused.test.tspass (40 tests).- Six test files that use
outbound.tsor the gate fixture pass (66 tests). bun x tsc --noEmitis clean.bun scripts/gate.tsran and only printed a "SKIPPING" line for a tool not installed here.
Not done
- No new test: the existing four failing tests already cover this behaviour.
- I did not run the full suite or
--rerun-each 10; the forge's check does that on the push.
The check on #12809 failed on a comment line in src/kernel/outbound.ts that was 129 columns wide, over the gate's 100-column limit. I rewrapped that comment and the type annotation under it, and pushed.
bun scripts/gate.ts now prints nothing, bun x tsc --noEmit is clean, and test/outbound-gate.test.ts still passes (17 tests). I did not re-run the wider test set. The gate only reads committed files, so it kept reporting the old line until I committed.
The behaviour of the fix is unchanged: outboundFetch still turns Bun's thrown CONNECT refusal back into the gate's refusal, and the unresolved name still says so.
I merged main into the branch and pushed. The branch now has no diff against main, so this pull adds nothing beyond what main already has.
Another change on main had already fixed the same refusal handling, and all three conflicting files (src/apps/egress.ts, src/kernel/outbound.ts, test/helpers/gate-fixture.ts) clashed with it. I took main's version of each rather than merge two fixes of the same thing. If you want the pull closed as redundant, that is now a reasonable call.
bun scripts/gate.ts and bun x tsc --noEmit are clean, and test/outbound-gate.test.ts and test/egress-refused.test.ts pass (42 tests).
The four red tests in
test/outbound-gate.test.tsnow pass. The cause was insrc/kernel/outbound.ts, not the tests. Under Bun 1.4.4,fetchthrough a proxy throwsERR_PROXY_TUNNELwhen the gate answers CONNECT with a refusal, and the response body is no longer readable. So the code that tells the gate's refusal from "does not resolve" never saw a response, and callers got a plain "Proxy refused to open a tunnel" error.What changed
src/kernel/outbound.ts:outboundFetchcatches that error when it carriesX-Forge-Egress: refusedand turns it back into the gate's refusal answer. It now reads the gate's words from the status line instead of the lost body, and still throwsGateRefusedError, or the "unresolved host" error when the name did not resolve.src/apps/egress.ts:refusedStatusnow puts the "… does not resolve" sentence on the status line too, as it already did for "refused by this forge:" sentences. Without this the client could not tell the two refusals apart.test/helpers/gate-fixture.ts: the fake gate now sends its sentence on the status line, as the real gate does. I changed this fixture rather than any test assertion.Checks run
test/outbound-gate.test.tsandtest/egress-refused.test.tspass (40 tests).outbound.tsor the gate fixture pass (66 tests).bun x tsc --noEmitis clean.bun scripts/gate.tsran and only printed a "SKIPPING" line for a tool not installed here.Not done
--rerun-each 10; the forge's check does that on the push.Closes #12792