-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Make auto-fixing of stack traces optional when using ssrLoadModule #7046
Labels
Comments
5 tasks
How so? They don't appear at all related to me |
Here's the code that does it (it doesn't call
|
sorry. after reading it a second time now I see it's not related. |
9 tasks
I sent a PR for this: #7048 |
benmccann
added
p3-downstream-blocker
Blocking the downstream ecosystem to work properly (priority)
and removed
enhancement: pending triage
labels
Feb 22, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Clear and concise description of the problem
When an error occurs during SSR, the stack trace needs fixing in order to be correct:
But if the error occurred during
ssrLoadModule
, Vite will fix the stack trace before the error is thrown. As discussed in #7045, this results in a broken sourcemap at best and a cryptic "TypeError: Line must be greater than or equal to 1, got -1" error at worst:It's possible to work around it...
...but when module loads are happening several function call boundaries away from the
try/catch
, this becomes problematic — all you can do is removessrFixStacktrace
from the top-levelcatch
and wrap everything except calls tossrLoadModule
with more granulartry/catch
blocks and dossrFixStacktrace
in those instead. It can get out of hand quite rapidly.Suggested solution
For me, the ideal would be if
ssrLoadModule
didn't fix stack traces at all (or log errors, for that matter) — there's nothing particularly special about errors that occur during module load rather than inside a function.Since that would be a breaking change, it could be an config option instead:
Alternative
Instead of putting the option in the config, it could be an option to
ssrLoadModule
itself. The docs suggest thatssrLoadModule
already takes an options object......though I think that's incorrect?
vite/packages/vite/src/node/server/index.ts
Lines 364 to 372 in 489a7f1
preserveStacktrace: true
could be a solution here.Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: