ReviewOS

home-lang/home

Bun parity: implement fetch.preconnect lifecycle

#359
Closed chris opened this 10 days ago ·
10 days ago

Corpus position 4139 (js/web/fetch/fetch-preconnect.test.ts) covers preconnected socket reuse and recovery.

Scope:

  • lower side-effect import "harness" correctly
  • implement fetch.preconnect() URL validation and local TCP connection establishment
  • reuse healthy preconnected sockets for fetch
  • replace sockets closed via end/terminate/shutdown before, during, or after request startup
  • support --fetch-preconnect=<url> subprocess behavior
  • provide structured preconnect errors with operation, URL/phase, cause, and composed stack
  • add permanent focused coverage and advance the zero-failure frontier.

First blocker: side-effect import lowering currently produces invalid import-call syntax.

10 days ago

Completed and pushed in 4f84bcd (feat(fetch): implement preconnect lifecycle).

Implemented:

  • correct side-effect harness import lowering
  • synchronous URL validation for fetch.preconnect()
  • a reusable local preconnect pool keyed by origin
  • request/response hook attachment to healthy preconnected sockets
  • one-shot fresh-socket retry when a pooled connection closes without response bytes
  • protection against paired end + close notifications consuming the retry twice
  • Bun socket terminate() parity and --fetch-preconnect=<url> child behavior
  • structured FetchPreconnectError with stable code, operation, phase, endpoint, cause, and composed stack
  • permanent full-file focused regression

Verification:

  • fetch-preconnect.test.ts: 12 passed, 0 failed/unsupported
  • focused preconnect lifecycle: pass
  • full zig build: pass

Corpus frontier through position 4139: 480 files, 6,874 passed, 281 todo, 172 allowed-empty, 0 failed, 0 unsupported.

Sign in to comment on this issue.