Skip to content

fix: preserve fetch bodies, cancellation and native prefetch semantics - #207

Open
OskarEichler wants to merge 1 commit into
margelo:mainfrom
OskarEichler:codex/nitro-fetch-body-transport-correctness
Open

fix: preserve fetch bodies, cancellation and native prefetch semantics#207
OskarEichler wants to merge 1 commit into
margelo:mainfrom
OskarEichler:codex/nitro-fetch-body-transport-correctness

Conversation

@OskarEichler

@OskarEichler OskarEichler commented Aug 27, 2026

Copy link
Copy Markdown

Fixes

  • Share body consumption/clone logic across Request and Response; support Blob, streams and URLSearchParams without silently dropping payloads.
  • Preserve RequestInit overrides, native and platform Request consumption, HTTP aborts, and streaming redirect decisions.
  • Preserve original non-UTF-8 response bytes; reuse UTF-8 codecs without runtime code generation; correct binary data URLs and BOM text decoding.
  • Register native requests before start/completion can race; make iOS prefetch await/join/error behavior real; use monotonic, finite cache TTLs.
  • Remove duplicated iOS response-building and unused method/final-URL wrappers.

Compatibility / breaking changes

  • Consumed/locked body reuse, invalid GET/HEAD bodies, invalid public Response construction, empty/undefined JSON, and unsupported FormData serialization now reject. Native FormData uploads remain supported.
  • text()/json() decode UTF-8 rather than interpreting a legacy charset header; byte readers preserve the original payload. Missing non-empty UTF-8 conversion now throws; install global codecs when needed.
  • iOS await prefetch() now waits and can reject. Non-finite prefetchCacheTtlMs rejects; zero/negative TTL skips completed cached responses, not in-flight joining.
  • Native manual redirects expose 3xx responses; browser manual redirects retain platform behavior. No package version or dependency upgrade is included.

Verification

  • Existing Jest and Bun suites: 10 passing, 2 existing TODOs. TypeScript, ESLint (one unrelated existing WebSocket plugin warning), Nitrogen and Bob build pass.
  • Focused external diagnostic harnesses cover body readers/clones/locks, Request transfer, platform fallback, data URLs, abort/redirect callbacks, validation and codecs. Real Foundation URLSession loopback checks: 13/13; Swift streaming callbacks: 5/5.
  • Android example Debug and iOS example Release builds pass, including tracing-enabled builds; iOS Simulator launch verified. React Doctor changed-source scan: 100/100, no issues.
  • The complete combined candidate was tested locally; this PR excludes independent Headers, inspector, storage, logging, Expo and podspec fixes. No test/spec files are added or modified.

Fixes #183. Fixes #185. Fixes #186. Fixes #188. Fixes #189. Fixes #190. Fixes #196. Fixes #197. Fixes #200. Fixes #201. Fixes #203. Fixes #206.

Changes were reviewed against upstream 627c77e. No test/spec files were added or modified. Release/version selection is left to the maintainers.

Consumer verification

All nine independent PR source overlays pass TypeScript. The combined fixes were backported to the existing 1.6.1 package without upgrading its dependency constraints. Both Android/iOS app variants, four production Metro bundles, 13 web builds, four extension builds and app lint pass. The installed artifact is immutable and its 269 non-metadata files match the build-verified candidate.

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@OskarEichler is attempting to deploy a commit to the Margelo Team on Vercel.

A member of the Team first needs to authorize it.

@riteshshukla04

Copy link
Copy Markdown
Collaborator

Too much work in same PR. Also highly AI slopped. Please make the PRs atomic .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment