-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vite eats proper error messages and replaces them with just [vite] Error when evaluating SSR module
#12631
Comments
The vite/packages/vite/src/node/ssr/ssrModuleLoader.ts Lines 205 to 226 in 1dfecc8
The error is rethrown here ( Maybe |
That's what VPS expects, but that doesn't actually seem to be the case here. I've updated the reproduction with helpful debug logs. As you can see the errors aren't thrown by |
Seems like it's a Vite regresssion: when pinning to (On a tangent: while the original error is much better, it isn't that helpful for most users either. I'm thinking maybe some kind of extra logged hint from Vite may help users that aren't that familiar with CJS/ESM compatibility problems.) |
I digged down a bit more. It seems the error is thrown to this line.
Yes, there was a regression (#12322). I think #12324 has fixed that. Though, #12324 removes the stacktrace from the log. |
I thought throwing the error with the stack would log the stack too. If it doesn't, maybe we should bring it back 🤔 Though I think that might log double error messages. |
I found the culprit: the error is being swallowed because I've udpated the reproduction with new debug logs. |
Ah, I see.
So I guess we should bring back stack trace message here, or we shouldn't pass e .
|
It seems #12324 forgot to test the error output after committing the newly reviewed code. I am going to fix that. |
It's actually very helpful that the user land stack trace is logged. Maybe Vite can wrap the original error with that additional information.
While the first part is the user land stack trace:
And the second part is the actual error, including the Vite land stack trace:
To avoid problems with In the future, Vite could add further information such as: Error while evaluating SSR module
at /node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-dev-runtime.js
at /pages/index/index.page.tsx
+ The following error seems to indicate a ESM-CJS compatibility problem, see https://vitejs.dev/cjs
ReferenceError: module is not defined
at eval (/node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-dev-runtime.js:8:3)
at instantiateModule (file:///home/rom/tmp/vite-not-helpful-error-messages/node_modules/.pnpm/vite@4.2.1_@types+node@18.15.10/node_modules/vite/dist/node/chunks/dep-79892de8.js:53996:15) |
We do show the origin importer's entry, but only for the vite/packages/vite/src/node/ssr/ssrModuleLoader.ts Lines 212 to 215 in 9697e64
|
Describe the bug
I am trying to build a website with vite-plugin-ssr. It's very hard to work because I don't actually get proper error messages in my console. Here is the discussion that initiated this bug report: vikejs/vike#743
CC @brillout
Reproduction
https://github.com/loxs/vite-not-helpful-error-messages
Steps to reproduce
This is just a new project created via
pnpm create vite-plugin-ssr@lates
, then enabling SSR in vite config.I have another commit to introduce a bug in the code: https://github.com/loxs/vite-not-helpful-error-messages/commit/712e1a2ef69650431de44afc5e8cec0da3a26e9a
If you run the project via
pnpm run dev
and visit http://localhost:3000You will see something like the error message here: vikejs/vike#743
It doesn't actually contain any useful debug info
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: