solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

[Bug?]: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["X-Error"]

Open frenzzy opened this issue 11 months ago • 2 comments

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:

  1. Install todomvc example using npm create solid
  2. Modify src/lib/api.ts#addTodo action to include the following line:
    throw new Error('Oops! Something went wrong 😅');
    
  3. 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

frenzzy avatar Jan 09 '25 07:01 frenzzy

hmm yeah it should probably escape it or something. If you return an Error it would work but not sure thats what you intend?

brenelz avatar Jan 24 '25 00:01 brenelz

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

brenelz avatar Mar 04 '25 03:03 brenelz