unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.89k stars 496 forks source link

500 error on invalid paths for cached event handlers #2657

Open cjpearson opened 1 month ago

cjpearson commented 1 month ago

Environment

Node v20.9.0, nitropack@2.9.7

Reproduction

https://stackblitz.com/edit/github-qj829h?file=server%2Froutes%2Findex.ts

Describe the bug

For a cached event handler, sending a request an invalidly encoded path will cause a 500 error. This is similar to #717. I would expect either a 404 error or for nitro to ignore the invalid path.

Additional context

No response

Logs

[nitro] [request error] [unhandled] URI malformed
  at decodeURI (<anonymous>)
  at getKey (./.nitro/dev/index.mjs:305:35)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async ./.nitro/dev/index.mjs:273:17
  at async Object.handler (./.nitro/dev/index.mjs:461:22)
  at async ./node_modules/h3/dist/index.mjs:1975:19
  at async Object.callAsync (./node_modules/unctx/dist/index.mjs:72:16)
  at async Server.toNodeHandle (./node_modules/h3/dist/index.mjs:2266:7)