vite-ssr icon indicating copy to clipboard operation
vite-ssr copied to clipboard

Error in url parsing?

Open xvaara opened this issue 3 years ago • 3 comments

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?

xvaara avatar Mar 27 '22 14:03 xvaara

Can you show an example of invalid URL? In general, this needs to throw error because it cannot continue rendering if it fails 🤔

frandiox avatar Apr 10 '22 13:04 frandiox

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.

xvaara avatar Apr 11 '22 12:04 xvaara

Yeah I think that's a good thing, independently from this issue, so you can provide a proper error page if everything goes wrong.

frandiox avatar Apr 11 '22 15:04 frandiox