fix: fix accumulated stacks in error overlay #16393
Merged
+24
−4
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.
Description
This looks like a regression of #15852. Since
template
element became a singleton, when I show the error overlay programatically withserver.hot.send
, it accumulates the messages in.stack
due to the mutation here:vite/packages/vite/src/client/overlay.ts
Line 269 in 5f0e6a3
The same test case looks like this in main:
Show screenshot
which now looks like this:
The background is that, I'm currently trying runtime error overlay ideas like #6274 and then I just spotted this odd behavior. Normally, the error overlay seems to happen after full client reload, so
template
is fresh, but when trying to show overlay multiple times, the stacks keep accumulating.I suppose calling
createTemplate
every time wouldn't hurt much, so I simply removedtemplate
singleton. Before the PR #15852, it wasinnerHTML
assignment, so I think it was making a fresh copy similarly.