Open pragmatic-recursion opened 2 days ago
I encountered this as well. Reverting to
"@auth/core": "^0.35.0",
"@auth/sveltekit": "1.5.3",
works as expected. Maybe this is an issue with the new customFetch
that @balazsorban44 added recently?
Here's the more-useful trace I get running locally with the newer releases:
TypeError: Illegal invocation: function called with incorrect `this` reference. See https://developers.cloudflare.com/workers/observability/errors/#illegal-invocation-errors for details.
at Object.apply
(file:///Users/jakemoves/projects/mixtape-project/mixtape/.wrangler/tmp/bundle-YxKLIk/checked-fetch.js:28:18)
at Object.apply
(file:///Users/jakemoves/projects/mixtape-project/mixtape/.wrangler/tmp/bundle-ul11C8/checked-fetch.js:28:18)
at null.<anonymous>
(file:///Users/jakemoves/projects/mixtape-project/mixtape/node_modules/.pnpm/@auth+core@0.36.0/node_modules/@auth/core/lib/actions/callback/oauth/callback.js:65:52)
at authenticatedRequest
... and the linked docs from Cloudflare at https://developers.cloudflare.com/workers/observability/errors/#illegal-invocation-errors
@jakemoves You're a life saver. I can finally ship. 🥹
Hmm. Unless you override customFetch, (which you really shouldn't in 99+% of the cases) we fall back to the globally available fetch
No clue why this would break Cloudflare yet...
Environment
Reproduction URL
https://github.com/pragmatic-recursion/auth-bug
Describe the issue
Running on Cloudflare Workers, not Pages! Works locally.
Server error
There is a problem with the server configuration.
Check the server logs for more information.
How to reproduce
1) Install Svelte https://developers.cloudflare.com/workers/frameworks/framework-guides/svelte/ npm create cloudflare@latest my-svelte-app -- --framework=svelte --experimental
2) Install @auth/sveltekit https://authjs.dev/reference/sveltekit npm install @auth/sveltekit
3) Add GitHub as a Provider
4) Deploy to Cloudflare Worker (Free)
It works locally but not when deployed
Expected behavior
Should be logged in