solid-start
solid-start copied to clipboard
[Bug?]: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["X-Error"]
Duplicates
- [X] I have searched the existing issues
Latest version
- [X] I have tested the latest version
Current behavior 😯
POST /_server returns 500 Internal Server Error
Expected behavior 🤔
POST /_server returns 200 OK
Steps to reproduce 🕹
Steps:
- Install
todomvcexample usingnpm create solid - Modify src/lib/api.ts#addTodo action to include the following line:
throw new Error('Oops! Something went wrong 😅'); - Open the page http://localhost:3000/ and add a todo item in UI.
Context 🔦
Console log shows an error:
[h3] [unhandled] TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["X-Error"]
at ServerResponse.setHeader (node:_http_outgoing:702:3)
It seams we should encode error message text here: packages/start/src/runtime/server-handler.ts#setHeader(h3Event,"X-Error",error.message)
Related:
- https://github.com/solidjs/solid-start/issues/1645
Your environment 🌎
Node: v23.5.0
SolidStart: v1.0.11
hmm yeah it should probably escape it or something. If you return an Error it would work but not sure thats what you intend?
This doesn't seem to return the invalid character error so this might be fixed. It still errors out the api call but thats expected since your throwing an error