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

Cannot read property 'split' of undefined - Netlify adapter #1911

Closed
Bradley-H opened this issue Jul 15, 2021 · 17 comments
Closed

Cannot read property 'split' of undefined - Netlify adapter #1911

Bradley-H opened this issue Jul 15, 2021 · 17 comments

Comments

@Bradley-H
Copy link

Bradley-H commented Jul 15, 2021

Describe the bug

When I upload my project I keep getting cannot read property of "split".

I suspect this has something to do with the adapter and not of Svelte itself since I can run a dev server just fine.

For whatever it might be worth, here is my project in question - https://github.com/Bradley-H/portfolio

Reproduction

upload to netlify

Logs

No response

System Info

It uploads to netlify just fine, no problem

Severity

blocking an upgrade

Additional Information

No response

here is my website on netlify if you need it - https://bradley-portfolio.netlify.app/

@0xPiyush
Copy link

Hello, I am facing the same issue, I tried deploying my Sveltekit app on netlify, on visiting the app,
https://sveltekit-pokedex.netlify.app/
it shows:
Cannot read property 'split' of undefined

Here's the netlify function logs:

4:12:50 PM: a210dba2 ERROR  TypeError: Cannot read property 'split' of undefined
    at parse_body (/var/task/index.js:2082:57)
    at respond (/var/task/index.js:2171:15)
    at render (/var/task/index.js:2495:10)
    at Runtime.handler (/var/task/index.js:2722:26)
    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)

The build succeeds and the website gets deployed but shows the above error, when testing locally using npm run build / npm run preview, the site works as intended, but shows the above error when deployed.
If you want to see the web app's code here it is:
https://github.com/0xPiyush/sveltekit-pokedex

using svelte netlify adapter. https://www.npmjs.com/package/@sveltejs/adapter-netlify

node: v14.17.2
Dev Dependencies:

"@sveltejs/adapter-netlify": "^1.0.0-next.22",
"@sveltejs/kit": "next",
"autoprefixer": "^10.3.1",
"svelte": "^3.34.0",
"tailwindcss": "^2.2.4"

netlify.toml file:

[build]
    command = "npm run build"
    publish = "build/"
    functions = "functions/"
[build.environment]
    NODE_VERSION = "14.17.2"

@JeanJPNM
Copy link
Contributor

By looking at the stacktraces it looks like the content-type header is undefined making it throw an error here

@0xPiyush
Copy link

@JeanJPNM but this only occurs on the deployed version and not when running/hosting locally.

@JeanJPNM
Copy link
Contributor

Can you show me the request data (headers, uri, etc)?

@JeanJPNM
Copy link
Contributor

Ok, so the whole website doesn't work

@JeanJPNM
Copy link
Contributor

Not only the main page responds with a 500 status, all the requests do

@0xPiyush
Copy link

Ok, so the whole website doesn't work

yes, none of the routes work on the deployed but if you clone the repo and run it locally, everything runs perfectly

@seenickcode
Copy link

@Bradley-H , @0xPiyush I'm getting the same issue as well (with Node v16.5.0). Have you both considered additionally posting the issue on one of Netlify's Github Issue trackers?

@0xPiyush
Copy link

@seenickcode I created a post in the netlify support forum and they said that they've seen numerous issues on this forum with Sveltekit, though this is the first of this nature, and asked me to add to this issue. I haven't created an issue on Netlify's issue trackers yet.

@benmccann
Copy link
Member

Don't post on Netlify's Github. This is our issue

const [type, ...directives] = headers['content-type'].split(/;\s*/);

@benmccann
Copy link
Member

I just moved that line of code: #1916

Can y'all try @sveltejs/kit@1.0.0-next.131 and see if it works any better?

@0xPiyush
Copy link

Thank you @benmccann #1916 fixed this issue.

@rchrdnsh
Copy link

I’m getting this error as well. I did some sleuthing by publishing previous deploys until the problem went away and then comparing netlify-adapter releases…I went back to version 1.0.0-next-20 and the issue went away for me…so I’m assuming maybe something was broken in next-21? Dunno if this is helpful or not.

@JeanJPNM
Copy link
Contributor

Are you using the most recent version of @sveltejs/kit?

@rchrdnsh
Copy link

kit: 131
netlify-adapter: 20

I just read Ben’s comment saying to try 131 with the latest adapter…I’ll try that next…

@rchrdnsh
Copy link

yes!

I updated to the latest of both kit and the netlify adaptor and the problem has indeed gone away for me...thank you @benmccann XD

@vojtechsedlak
Copy link

Running into this issue again with kit: 286 and netlify-adapter: 47. The build compiles and previews fine locally, but on Netlify results in the cannot read property 'split' of undefined error despite no errors getting thrown in the deployment. Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants