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
TypeError: RequestInit: duplex option is required when sending a body.
at fetch (/Users/ben/projects/svelte-surfshots/node_modules/.pnpm/[email protected]/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
ReadableStream
to a bucket using SvelteKit 1.0.0-next.526 and the storage-js client like so:I got this error:
To Reproduce
auth-helpers
node:stream
Readable or anode: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
Additional context
{duplex: 'half' }
or{ duplex: 'full' }
option to be passed to theRequestInit
when performing a fetch with aReadableStream
. See here.TypeError
when the option isn't present during a streaming fetch call in v5.12.0. See hereauth-helper
down to thefetch
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 containmethod
,body
andheader
The text was updated successfully, but these errors were encountered: