ReviewOS

home-lang/home

Bun parity: release canceled fetch stream roots

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

Port js/web/fetch/fetch-stream-cancel-leak.test.ts from the copied Bun corpus.

Required behavior:

  • resolve fetch once an incomplete chunked response has headers and a readable chunk without waiting for connection close
  • make reader.cancel() and body.cancel() detach the client stream from the open keep-alive transport
  • release the fetch stream lifecycle root idempotently so canceled bodies become collectible
  • provide structured phase, endpoint, reason/cause, and composed stack data for cancellation lifecycle failures
  • add a permanent focused regression and advance corpus position 4143 with zero failures or unsupported tests

Tracked under #66.

10 days ago

Completed in ff0de2c and pushed directly to main.

Implemented:

  • early fetch resolution for incomplete chunked responses once headers and a complete readable chunk arrive
  • explicit live response-stream lifecycle roots
  • reader.cancel() and body.cancel() release the root, clear stream/socket references, and terminate the open transport idempotently
  • FetchStreamLifecycleError with ERR_FETCH_STREAM_LIFECYCLE, operation, phase, endpoint, reason, live-root count, cause, and composed stack
  • permanent focused regression for both upstream cancellation paths

Validation:

  • indexed Bun corpus position 4143: 2 passed, 0 failed, 0 todo, 0 unsupported
  • adjacent positions 4142-4143: 4 passed, 0 failed, 0 unsupported
  • focused cancellation regression: passed
  • zig build --cache-dir /private/tmp/home-zig-abi-cache: passed

Sign in to comment on this issue.