solid-start
solid-start copied to clipboard
[Bug?]: SolidStart produces invalid flash cookies
Duplicates
- [X] I have searched the existing issues
Latest version
- [X] I have tested the latest version
Current behavior 😯
Server sets the following set-cookie header:
set-cookie: flash={"url":"/_server%3Fid%3D%252Fsolid-start%252Fexamples%252Fwith-auth%252Fsrc%252Flib%252Findex.ts%26name%3D%2524%2524function1","result":"Usernames must be at least 3 characters long","error":true,"input":[[["redirectTo","/"],["loginType","login"],["username",";"],["password",""]]]}; Secure; HttpOnly;
User sees:
{
"statusCode": 500,
"stack": []
}
Server displays an error:
[h3] [unhandled] SyntaxError: Unterminated string in JSON at position 243 (line 1 column 244)
at JSON.parse (<anonymous>)
... 7 lines matching cause stack trace ...
at async Server.toNodeHandle (file:///solid-start/node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:2249:7) {
cause: SyntaxError: Unterminated string in JSON at position 243 (line 1 column 244)
at JSON.parse (<anonymous>)
at initFromFlash (/solid-start/node_modules/.pnpm/@[email protected]_@[email protected][email protected]_@[email protected]_@vites_g4axoxquuc27oifb2hw6quhyia/node_modules/@solidjs/start/dist/server/pageEvent.js:11:20)
at createPageEvent (/solid-start/node_modules/.pnpm/@[email protected]_@[email protected][email protected]_@[email protected]_@vites_g4axoxquuc27oifb2hw6quhyia/node_modules/@solidjs/start/dist/server/pageEvent.js:35:19)
at async eval (/solid-start/node_modules/.pnpm/@[email protected]_@[email protected][email protected]_@[email protected]_@vites_g4axoxquuc27oifb2hw6quhyia/node_modules/@solidjs/start/dist/server/handler.js:45:25)
at async _callHandler (file:///solid-start/node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:1821:16)
at async _callHandler (file:///solid-start/node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:1821:16)
at async file:///solid-start/node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:1962:19
at async Object.callAsync (file:///solid-start/node_modules/.pnpm/[email protected]/node_modules/unctx/dist/index.mjs:72:16)
at async Server.toNodeHandle (file:///solid-start/node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:2249:7),
statusCode: 500,
fatal: false,
unhandled: true,
statusMessage: undefined,
data: undefined
}
Expected behavior 🤔
- The server should produce valid
flashcookies (e.g., encode non-ASCII symbols). - The server should handle invalid cookies correctly (e.g., ignore them instead of failing).
Steps to reproduce 🕹
Steps:
- Run and open the
with-authexample. - Disable JavaScript in DevTools.
- Enter
;or any non-ASCII symbol into the Username field. - Submit the form.
Context 🔦
No response
Your environment 🌎
I have reproduced the issue using the latest commit in the main brunch on Node.js v22.9.0