Skip to content

fix: preserve binary request bodies over base64 - #138

Closed
PradyumnaShome wants to merge 1 commit into
margelo:mainfrom
PradyumnaShome:fix/binary-request-bodies-base64
Closed

fix: preserve binary request bodies over base64#138
PradyumnaShome wants to merge 1 commit into
margelo:mainfrom
PradyumnaShome:fix/binary-request-bodies-base64

Conversation

@PradyumnaShome

Copy link
Copy Markdown

Summary

  • encode ArrayBuffer and typed-array request bodies as base64 at the existing string wire boundary
  • decode that base64 into the actual upload bytes on iOS and Android
  • cover full buffers, typed-array subviews, empty bodies, non-ASCII bytes, and the worklet-safe fallback
  • keep string, URLSearchParams, and form-data handling unchanged

Why

Binary request bodies are normalized in JavaScript today, but bodyBytes is then left unset. Even if it is provided, Android currently uploads a one-byte placeholder and iOS does not attach it to the request. This can drop or corrupt binary uploads.

This draft is an interim correctness fix: it intentionally retains the current bodyBytes?: string base64 transport and does not change the Nitro spec or generated ABI.

Tests

  • bun --cwd packages/react-native-nitro-fetch test --runInBand src/__tests__/fetch.test.ts
  • bun --cwd packages/react-native-nitro-fetch test --runInBand
  • bun typecheck
  • bun lint (0 errors; 2 pre-existing no-shadow warnings)
  • git diff --check

Limitations / follow-up

The new coverage is a JavaScript contract test for the current base64 wire format. I did not run an iOS or Android app build in this checkout, so native decoding is not exercised by an integration test here.

#112 proposes the broader ArrayBuffer transport and generated binding changes. That remains the preferred follow-up; this draft is deliberately narrower so the request-body correctness fix can be reviewed independently without an ABI change.

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@PradyumnaShome
PradyumnaShome marked this pull request as ready for review July 11, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants