-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Error thrown when returning endpoint Response without body #1351
Comments
Arguably we should provide a more informative error, but this is an error, no? When would a 200 GET response not have a body? |
I agree with Rich,... btw no body and empty body is not same thing. |
A more descriptive error message would be great since I ran into it a couple times and it wasn't clear what was going on. I do agree that it doesn't entirely make sense for there to be no body but when I'm just testing if something works sometimes I forget to add body stuff, and then the error makes it seem like the thing I'm testing doesn't work! |
I ran into the same issue today. The error message was "Cannot read property 'length' of undefined". My mistake was that I copied this snippet which did not include the body in the response and didn't think while copying. https://kit.svelte.dev/docs#ssr-and-javascript-ssr return {
headers: {
'set-cookie': [cookie1, cookie2]
}
}; |
I get this on a 200 DELETE though and in that case a body doesn't make sense, right? |
Describe the bug
If an endpoint returns an object without the
body
key specified, an error is thrown. This only seems to happen with a 200 status code.Stack trace below.
Expected behavior
No error thrown, or at least a more descriptive one.
Stacktraces
Stack trace
Information about your SvelteKit Installation:
Tested on
@sveltejs/[email protected]
,[email protected]
,[email protected]
.Severity
This isn't too severe since it's very easy to return an empty object as the body, but the error message doesn't really help.
Additional context
Seems like it's trying to hash the body for the ETag header, but
body
is undefined.The text was updated successfully, but these errors were encountered: