You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
Upload stream fetch request fails in SvelteKit #146
TypeError: RequestInit: duplex option is required when sending a body.
at fetch (/Users/ben/projects/svelte-surfshots/node_modules/.pnpm/undici@5.14.0/node_modules/undici/index.js:105:13)
To Reproduce
Follow supabase install instructions for a new SvelteKit project here
Set up a public bucket and add upload permission policy for any authenticated user
Try to upload either a node:stream Readable or a node:stream/web ReadableStream from a +server.ts file on a route of your choosing (I tried both and they threw the same error)
Expected behavior
The file should be added to the bucket
System information
OS: macOS 12.6
Browser (if applies): Chrome 109.0.5414.119
Version of supabase-js: 2.2.3
Version of Node.js: 18.13.0 (lts)
Additional context
Recently the whatwg spec has been shifted to require a {duplex: 'half' } or { duplex: 'full' } option to be passed to the RequestInit when performing a fetch with a ReadableStream. See here.
Undici started following the spec and throwing a TypeError when the option isn't present during a streaming fetch call in v5.12.0. See here
SvelteKit pinned Undici at v5.12.0 in a recent release (now they are up to v5.14.0)
After digging around in storage-js and tracking the (rather labyrinthine) load sequence from auth-helper down to the fetch call the upload eventually flushes to, I determined that implementation was indeed calling undici and had no extra mechanism to pass in more options to the RequestInit. The lines below fix the request init to only contain method, body and header
Bug report
Not sure if this is the ideal place to file this bug, but I decided on here because my client implementation is the one recommended here.
Describe the bug
When trying to upload a
ReadableStreamto a bucket using SvelteKit 1.0.0-next.526 and the storage-js client like so:I got this error:
TypeError: RequestInit: duplex option is required when sending a body. at fetch (/Users/ben/projects/svelte-surfshots/node_modules/.pnpm/undici@5.14.0/node_modules/undici/index.js:105:13)To Reproduce
auth-helpersnode:streamReadable or anode:stream/webReadableStream from a+server.tsfile on a route of your choosing (I tried both and they threw the same error)Expected behavior
The file should be added to the bucket
System information
Additional context
{duplex: 'half' }or{ duplex: 'full' }option to be passed to theRequestInitwhen performing a fetch with aReadableStream. See here.TypeErrorwhen the option isn't present during a streaming fetch call in v5.12.0. See hereauth-helperdown to thefetchcall the upload eventually flushes to, I determined that implementation was indeed calling undici and had no extra mechanism to pass in more options to the RequestInit. The lines below fix the request init to only containmethod,bodyandheader