ReviewOS

home-lang/home

S3 stream errors: root parked JS exceptions across GC

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

Tracks a focused part of #66.

At Bun source pin 4982b91e3702094330f3be3883354c52b8c01323, the native S3 corpus currently reports 74 pass / 1 fail / 6 TODO. The sole failure is js/bun/s3/s3-stream-error-gc.test.ts: a stream error parked before consumption is recycled after forced GC (observed as a decoy TypeError).

Root cause: Home stores Result.StreamError.JSValue as an unrooted raw jsc.JSValue. Bun’s authoritative Rust implementation stores it as jsc::strong::Optional and releases that ownership only when the stream result is consumed or discarded.

Acceptance criteria:

  • Port strong ownership through all shared stream-error producers and consumers, without disabling/suppressing GC.
  • The unchanged s3-stream-error-gc.test.ts passes.
  • The full native S3 directory passes with no failures.
  • Existing cancellation/leak and related fetch/request stream error paths remain passing.
  • Add focused local regression coverage if the corpus test is not part of the normal local aggregate.
10 days ago

Fixed and pushed in 8cd0a29b2 (fix(runtime): retain deferred stream errors).\n\nPorted Bun's authoritative StreamError::JSValue(jsc::strong::Optional) ownership model at source pin 4982b91e3702094330f3be3883354c52b8c01323 across S3, fetch, request-body, byte-stream, promise, buffering, and pipe producer/consumer paths. Roots are created when errors enter a stream and released exactly once when consumed or discarded; GC remains fully enabled.\n\nValidation with ./zig-out/bin/home-debug:\n- unchanged js/bun/s3/s3-stream-error-gc.test.ts: 1 pass / 0 fail\n- full js/bun/s3: 75 pass / 0 fail / 6 TODO across 11 files\n- s3-stream-cancel-leak.test.ts: 1/1\n- fetch-stream-cancel-leak.test.ts: 2/2\n- server-response-stream-leak.test.ts: 1/1\n- native-source-onclose-leak.test.ts: 4/4\n- streams.test.js: 71 pass / 0 fail / 1 TODO\n- regression/issue/22353.test.ts: 1/1\n- local native fetch-abort and stream-wrap lifecycle checks: pass\n- zig build debug -j1, Pickier, and diff checks: pass\n\nThe previously failing S3 directory moved from 74 pass / 1 fail / 6 TODO to 75 pass / 0 fail / 6 TODO.

Sign in to comment on this issue.