ReviewOS

home-lang/home

Bun parity: accept RequestInit fetch shorthand arguments

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

Corpus location

  • Position: 4127
  • File: js/web/fetch/fetch-args.test.ts
  • First observed failure: fetch(RequestInit, headers): "[object Object]" cannot be parsed as a URL

Required parity

  • Accept Bun's object-shaped first argument when it contains url and request-init fields.
  • Preserve normal Request and Request-subclass behavior, including headers supplied by subclasses.
  • Apply the second argument as an override without eagerly reading it when conversion of the first argument throws.
  • Preserve getter evaluation/error propagation semantics for request-init fields.
  • Reject invalid headers, URLs, redirects, conflicting proxy/unix options, invalid TLS CA values, and failing stream bodies before any network request is sent.
  • Surface stable structured errors with operation/input context, causes, and useful composed stacks rather than opaque conversion failures.

Completion gate

  • Make the complete copied Bun corpus file pass (apart from explicit upstream todos, if any).
  • Add a focused regression and pin it in the permanent HTTP/web mini-suite.
  • Keep the full copied-corpus accounting and project build green.

Parent tracker: #66

10 days ago

Implemented and pushed to main in d607cacd3fb04b909d577f4e2f8f06c3cd79441a.

  • Added one ordered fetch argument-normalization path for URL-like values, Bun object-shaped { url, ...init } inputs, Request instances/subclasses, and second-argument overrides.
  • Init getters are evaluated before transport work, while input URL conversion still happens first; conversion/getter failures do not send a request.
  • Headers, redirect mode, proxy/unix conflicts, and TLS CA values are validated before transport dispatch.
  • Argument failures now expose ERR_FETCH_INPUT, fetch.arguments.normalize, phase/property/type context, a cause, and a composed stack.
  • Added a focused regression and pinned the file in the permanent HTTP/web mini-suite.

Verification:

  • js/web/fetch/fetch-args.test.ts: 47 passed, 0 failed, 0 todo, 0 unsupported
  • focused fetch-argument regression: passed
  • permanent HTTP/web tail queue: passed
  • zig build --cache-dir /private/tmp/home-zig-abi-cache: passed

Sign in to comment on this issue.