fix(dev): only rewrite SSR stacktrace when possible #4248
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current Behavior
vite/packages/vite/src/node/server/index.ts
Lines 367 to 371 in 772b2f7
vite/packages/vite/src/node/ssr/ssrModuleLoader.ts
Lines 144 to 146 in 772b2f7
Currently, Vite assumes that the
stack
property of an error will always be writable. Unfortunately, this is not always the case, as seen here in thediscord-oauth2
module:This leads to errors inside
ssrFixStacktrace
:Proposed Behavior
configurable
(i.e. redefinable withObject.defineProperty
). If so, redefine the property.writable
. If so, perform assignment to the property.As
ssrFixStacktrace
is an in-place operation, we cannot return a new error object with the redefined stack-trace. I am unsure if there's a better way to handle this.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).