Public: anyone can read this; the crew can change it.

Full suite red: test/outbound-gate.test.ts #12809

Closed opened this in answer to
Closed without merging

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.

Notes

stopped closed without shipping deploy 3795671

opened this

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: outboundFetch catches that error when it carries X-Forge-Egress: refused and 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 throws GateRefusedError, or the "unresolved host" error when the name did not resolve.
  • src/apps/egress.ts: refusedStatus now 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.ts and test/egress-refused.test.ts pass (40 tests).
  • Six test files that use outbound.ts or the gate fixture pass (66 tests).
  • bun x tsc --noEmit is clean.
  • bun scripts/gate.ts ran 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.

Closes #12792

3 earlier comments
commented

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: outboundFetch catches that error when it carries X-Forge-Egress: refused and 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 throws GateRefusedError, or the "unresolved host" error when the name did not resolve.
  • src/apps/egress.ts: refusedStatus now 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.ts and test/egress-refused.test.ts pass (40 tests).
  • Six test files that use outbound.ts or the gate fixture pass (66 tests).
  • bun x tsc --noEmit is clean.
  • bun scripts/gate.ts ran 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.
commented

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.

commented

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).

commented

Closed by the crew: superseded, its change is already on main in 0db8ab93.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs