ReviewOS

home-lang/home

Bun parity: complete Request and Response body semantics

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

Upstream coverage

  • js/web/fetch/body.test.ts (corpus position 4118)

Required parity

  • accept Bun-compatible ArrayBuffer, SharedArrayBuffer, and typed-array bodies
  • preserve correct SharedArrayBuffer branding and copy semantics
  • compare Blob/File values semantically across backing representations
  • round-trip Bun.file-backed FormData entries lazily through multipart
  • reject null Request/Response FormData bodies with structured TypeErrors
  • keep bodyUsed correct across JSON fast paths
  • prevent async assertion failures from being attributed to a later test

Error contract

Body/FormData failures must retain operation, content type, cause, and composed stack metadata. Assertion failures must identify the originating test even when they settle asynchronously.

Acceptance

The upstream file passes all 346 runnable assertions with 4 upstream todos and 0 failed/unsupported cases, plus the permanent web regression queue and repository build remain green.

10 days ago

Completed in bcc2268.

Implemented Bun-compatible buffer and Body semantics across Request/Response:

  • crypto.getRandomValues accepts ArrayBuffer, SharedArrayBuffer, and supported views
  • fallback SharedArrayBuffer has a distinct brand/prototype and correct copy behavior
  • Body byte/content-length/direct-view conversion recognizes shared backing
  • Blob/File strict equality compares observable content and metadata across backing representations
  • Bun.file-backed FormData entries remain lazy and serialize correctly as sparse multipart Files
  • null Request/Response FormData bodies reject with structured ERR_BODY_FORM_DATA TypeErrors
  • Request/Response JSON consumption consistently updates bodyUsed
  • assertion failures carry ERR_BUN_TEST_ASSERTION, operation/test/source metadata, and async matcher failures retain their originating test name and corrected composed frame

Verification:

  • js/web/fetch/body.test.ts: 346 passed, 4 upstream todo, 0 failed, 0 unsupported
  • permanent HTTP/web tail queue: passing
  • zig fmt --check: passing
  • git diff --check: passing
  • repository-wide zig build: passing

Sign in to comment on this issue.