Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vercel Deployments are erroring only in prod (not in dev, not in preview) #10918

Closed
bent101 opened this issue Oct 25, 2023 · 10 comments
Closed
Labels
pkg:adapter-vercel Pertaining to the Vercel adapter

Comments

@bent101
Copy link

bent101 commented Oct 25, 2023

Describe the bug

see this discussion for more info

Reproduction

repro, just a skeleton project with a routes/+page.svelte and a routes/+page.ts loading dummy json
failed vercel deployment

Logs

TypeError: Failed to parse URL from [object Request]
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.fetch (file:///var/task/.svelte-kit/output/server/index.js:2372:12)
at async file:///var/task/.svelte-kit/output/server/index.js:740:20
at async file:///var/task/.svelte-kit/output/server/index.js:629:86
at async Promise.all (index 0)
at async unwrap_promises (file:///var/task/.svelte-kit/output/server/index.js:629:9)
at async load_data (file:///var/task/.svelte-kit/output/server/index.js:733:25)
at async file:///var/task/.svelte-kit/output/server/index.js:2106:18 {
[cause]: TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:405:5)
at new URL (node:internal/url:637:13)
at new Request (node:internal/deps/undici/undici:7132:25)
at fetch2 (node:internal/deps/undici/undici:10715:25)
at Object.fetch (node:internal/deps/undici/undici:11574:18)
at fetch (node:internal/process/pre_execution:242:25)
at n (/var/task/___vc/__launcher/__launcher.js:14:5526)
at fetch (file:///var/task/.svelte-kit/output/server/index.js:2394:18)
at #options.hooks.handleFetch (file:///var/task/.svelte-kit/output/server/index.js:2919:79)
at Object.fetch (file:///var/task/.svelte-kit/output/server/index.js:2372:33) {
input: '[object Request]',
code: 'ERR_INVALID_URL'
}
}

System Info

vercel :D

Severity

blocking all usage of SvelteKit

Additional Information

No response

@lennart-jaervinen
Copy link

I have the exact same error since I deployed yesterday (nothing grave did really change within the code and reverting the changes and re-deploying didn't fix the error. I'm also using the adapter-vercel).

Glad I only pushed to staging yesterday, but this blocks all live deployments, which I will need to hold until the issue gets resolved.

@dummdidumm
Copy link
Member

dummdidumm commented Oct 25, 2023

It looks like the cause is nodejs/undici#2374 in combination with us always polyfilling undici. I suspect that Vercel bumped the Node 18 version recently, which includes this bug, and therefore all subsequent deployments fail. As a quickfix you can tell Vercel to deploy to Node 16 on the settings main page (scroll down to "Node.js version"), or to deploy to the edge runtime instead (if that's possible for your setup).

@dummdidumm dummdidumm added the pkg:adapter-vercel Pertaining to the Vercel adapter label Oct 25, 2023
@dummdidumm
Copy link
Member

So it seems the linked issue was red herring, as it was closed as a duplicate of something else and that issue was fixed and released a few days ago - and I can reproduce this with the latest version of undici. I'm very confused now as to what could cause this.

@benmccann
Copy link
Member

Hmm. They edited the issue it was closed in favor of. They were previously saying nodejs/node#50263. Perhaps this is caused by that issue?

@dummdidumm
Copy link
Member

Mhm okay. But why is the polyfill failing with a older versions of undici, too, then? It's very strange, and I'm tempted to add something to the polyfill code to check for specific node versions and not apply them there.

@benmccann
Copy link
Member

We only need to polyfill < Node 18.11:

// TODO: remove this once we only support Node 18.11+ (the version multipart/form-data was added)

I'd be fine with removing the polyfill on older Node versions. Though it's unclear to me what Node versions are being affected by this bug and whether that would fix anything.

@dummdidumm
Copy link
Member

We can't completely, crypto is still webcrypto in node - but yeah, we could add a check for the node version and avoid it. In my local testing this fixes the issue.

dummdidumm added a commit that referenced this issue Oct 25, 2023
Rich-Harris added a commit that referenced this issue Oct 25, 2023
* fix: only apply some polyfills below node 18.11

related to #10918

* Update packages/kit/src/exports/node/polyfills.js

Co-authored-by: Ben McCann <[email protected]>

* be more defensive

* be more defensive

---------

Co-authored-by: Rich Harris <[email protected]>
Co-authored-by: Ben McCann <[email protected]>
@dummdidumm
Copy link
Member

Sveltekit 1.27.1 hopefully fixes this

@echocrow
Copy link

Temporarily falling back to node16 on Vercel as suggested in #10918 (comment) circumvented the issue for us.

Just updated SvelteKit to 1.27.1 and reverted to node18; can confirm server-side fetches are working again. ✅

Thanks for the quick hotfix @dummdidumm!

@benmccann
Copy link
Member

Thanks for confirming the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:adapter-vercel Pertaining to the Vercel adapter
Projects
None yet
Development

No branches or pull requests

5 participants