solidjs / solid-start

SolidStart, the Solid app framework
https://start.solidjs.com
MIT License
4.93k stars 371 forks source link

[Bug?]: server function that contain await prisma function will throws error #1514

Closed Huliiiiii closed 1 week ago

Huliiiiii commented 1 month ago

Duplicates

Latest version

Current behavior 😯

async function WithOutAwait(){
    "use server"
    prisma.$executeRaw`SELECT * From User`;
    return console.log("WithOutAwait: ok");

}

async function WithAwait(){
    "use server"
    await prisma.$executeRaw`SELECT * From User`;
    return console.log("WithAwait: ok");
}

<button onClick={()=>WithOutAwait()} /> 
// Click: WithOutAwait: ok
<button onClick={()=>WithAwait()} /> 
// Click: Error:
// [nitro] [request error] [unhandled] Invalid character in header content ["X-Error"]
//   at ServerResponse.setHeader (node:_http_outgoing:706:3)
//   at setResponseHeader (/D:/**/solid-project/.output/server/chunks/runtime.mjs:2528:18)
//   at /D:/**/solid-project/.output/server/chunks/runtime.mjs:5724:1057
//   at Object.ye$1 [as handler] (/D:/**/solid-project/.output/server/chunks/runtime.mjs:6067:6371)
//   at async /D:/**/solid-project/.output/server/chunks/runtime.mjs:3039:19
//   at async Object.callAsync (/D:/**/solid-project/.output/server/chunks/runtime.mjs:5340:16)
//   at async Server.toNodeHandle (/D:/**/solid-project/.output/server/chunks/runtime.mjs:3305:7)

Expected behavior 🤔

The second button should work like the first.

Steps to reproduce 🕹

Copy code in solid-start template with prisma can reproduce this.

Context 🔦

No response

Your environment 🌎

OS: Microsoft Windows [version 10.0.22631.3593]
Node: 21.6.1
Bun: 1.1.10 (use as package manager)
Pnpm: 9.1.2
Solid-Start: 1.0.0
lxsmnsyc commented 1 month ago

Whether or not the use of await is there is irrelevant, seems like there's an included header with invalid characters.

lxsmnsyc commented 1 month ago

@ryansolid seems like the X-Error setHeader needs some character sanitation

ryansolid commented 1 month ago

Thanks.