trpc icon indicating copy to clipboard operation
trpc copied to clipboard

bug: ReadableStream uploading is not supported on safari

Open ankitjena opened this issue 5 months ago โ€ข 1 comments

Provide environment information

System:
    OS: macOS 15.5
    CPU: (12) arm64 Apple M4 Pro
    Memory: 547.69 MB / 24.00 GB
    Shell: 5.9 - /opt/homebrew/bin/zsh
  Binaries:
    Node: 22.13.1 - ~/.nvm/versions/node/v22.13.1/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v22.13.1/bin/npm
    pnpm: 10.12.1 - ~/.nvm/versions/node/v22.13.1/bin/pnpm
    bun: 1.2.18 - ~/.bun/bin/bun
    Watchman: 2025.07.28.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 139.0.7258.127
    Safari: 18.5
  npmPackages:
    @tanstack/react-query: ^4.40.0 => 4.40.0
    @trpc/client: ^10.45.2 => 10.45.2
    @trpc/react-query: ^10.45.2 => 10.45.2
    @trpc/server: ^10.45.2 => 10.45.2
    react: ^18.3.1 => 18.3.1
    typescript: ~5.8.3 => 5.8.3

Describe the bug

TRPCClientError: ReadableStream uploading is not supported

Getting this error in a few .mutate or mutate/mutateAsync calls using useMutations in safari. It works perfectly well in Chrome and Firebox based browsers.

I initially thought it might be due to batching and changed httpBatchLink to httpLink, also tried to use splitLink while checking for Safari but getting the same issue. It also doesn't fail for all mutations but only some.

Link to reproduction

N/A

To reproduce

N/A

Additional information

No response

๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Contributing

  • [ ] ๐Ÿ™‹โ€โ™‚๏ธ Yes, I'd be down to file a PR fixing this bug!

ankitjena avatar Aug 18 '25 12:08 ankitjena

Unfortunately Streaming Request bodies in fetch are not available in Safari right now :/

Image

Source: https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch#browser_compatibility

I'm not sure right now how much is dependent on the internal httpLink / httpBatchLink implementation or the typing of your RPC function, but maybe you have some datatypes in your function which are implemented as ReadableStream uploads in trpc.

Right now, your only bet is to avoid those datatypes, for example, by encoding every binary type to Base64 and sending it as one big string. (This is only speculation, I did not test this).

@ankitjena Can you share more of the procedures you defined on your router which are failing?

bjesuiter avatar Sep 16 '25 23:09 bjesuiter