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
This bug causes any use of the fetch method (the one provided in a route's load callback) to error. (No matter if the request is valid, invalid, local, external, etc.) when running the project locally with Wrangler 2.
It's caused by this issue and this commit. The package Wrangler 2 uses for requests in its local emulator (Undici) expects the credentials header on a request to be non-null, even though the real runtime doesn't mind. This throws an error, cancelling the request. This is making development frustrating as I can't run my app locally at all.
At the time this hack was added, the workers runtime didn't support the credentials header set on a request - this looks to be support now. After removing the removing the credentials: undefined override on this line, the issue is fixed. I can confirm it's now working on Wrangler 1, 2, and the 'real' workers runtime in the cloud!
I've made a tiny repo that demonstrates the problem.
git clone https://github.com/OttoHatt/sveltekit-broken-fetch
cd sveltekit-broken-fetch/
npm i
npm run build
npm run demo
Logs
TypeError: Failed to construct 'Request': The provided value 'undefined' is not a valid enum value of type RequestCredentials.
at new Request (C:\Users\......\Downloads\sveltekit-broken-fetch\node_modules\undici\lib\fetch\request.js:288:15)
at new Request (C:\Users\......\Downloads\sveltekit-broken-fetch\node_modules\@miniflare\core\src\standards\http.ts:407:13)
at Object.construct (C:\Users\......\Downloads\sveltekit-broken-fetch\node_modules\@miniflare\core\src\plugins\core.ts:69:29)
at fetch (C:\Users\......\Downloads\sveltekit-broken-fetch\.svelte-kit\cloudflare\_worker.js:1751:36)
at load2 (C:\Users\......\Downloads\sveltekit-broken-fetch\.svelte-kit\cloudflare\_worker.js:218:31)
at load_node (C:\Users\......\Downloads\sveltekit-broken-fetch\.svelte-kit\cloudflare\_worker.js:1839:32)
at respond$1 (C:\Users\......\Downloads\sveltekit-broken-fetch\.svelte-kit\cloudflare\_worker.js:2078:20)
at resolve (C:\Users\......\Downloads\sveltekit-broken-fetch\.svelte-kit\cloudflare\_worker.js:2417:105)
at respond (C:\Users\......\Downloads\sveltekit-broken-fetch\.svelte-kit\cloudflare\_worker.js:2373:22)
at Object.fetch (C:\Users\......\Downloads\sveltekit-broken-fetch\.svelte-kit\cloudflare\_worker.js:2657:15)
Describe the bug
Problem
This bug causes any use of the
fetch
method (the one provided in a route'sload
callback) to error. (No matter if the request is valid, invalid, local, external, etc.) when running the project locally with Wrangler 2.It's caused by this issue and this commit. The package Wrangler 2 uses for requests in its local emulator (Undici) expects the
credentials
header on a request to be non-null, even though the real runtime doesn't mind. This throws an error, cancelling the request. This is making development frustrating as I can't run my app locally at all.At the time this hack was added, the workers runtime didn't support the
credentials
header set on a request - this looks to be support now. After removing the removing thecredentials: undefined
override on this line, the issue is fixed. I can confirm it's now working on Wrangler 1, 2, and the 'real' workers runtime in the cloud!Fix
Reproduction
I've made a tiny repo that demonstrates the problem.
Logs
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: