vite-ssr
vite-ssr copied to clipboard
Error in url parsing?
Hey, I've had a build vite-ssr express server crash with the error message:
node:internal/errors:465
ErrorCaptureStackTrace(err);
^
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:372:5)
at onParseError (node:internal/url:563:9)
at new URL (node:internal/url:643:5)
at createUrl (/home/user/app/@app/client/dist/server/main.js:5767:10)
at /home/user/app/@app/client/dist/server/main.js:5977:11
at /home/user/app/@app/server/dist/middleware/installSSR.js:57:65
at Layer.handle [as handle_request] (/home/user/app/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/home/user/app/node_modules/express/lib/router/index.js:323:13)
at /home/user/app/node_modules/express/lib/router/index.js:284:7
at param (/home/user/app/node_modules/express/lib/router/index.js:360:14) {
input: 'http://${ip}:${port}/',
code: 'ERR_INVALID_URL'
}
should there be a try/catch in the createUrl function in the router?
Can you show an example of invalid URL? In general, this needs to throw error because it cannot continue rendering if it fails 🤔
I can't find anything weird in my logs around that time. Since it crashed the express server it didn't either log the url or timestamp for it.
It's only happened twice, in production. Maybe I'll need to wrap the ssr render in try catch to be on the safe side and catch the error.
Yeah I think that's a good thing, independently from this issue, so you can provide a proper error page if everything goes wrong.