-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix: error overlay message escape #12305
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: f6dc9c2 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
this.text('#message-content', err.message, true); | ||
// Only set as html if escaped. We're only sure it's escaped if name is part | ||
// of the error, ie. we transformed it as we wanted. | ||
// TODO: capture error at the source and transform it there |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Princesseuh I tried many things but couldn't find from where the error on initial render is coming. Basically the flow is as follow:
- you have failing code: escaped
- you update your failing code but it's still failing, you save
- on initial render, it's not escaped (the error has not been enhanced by us yet, where does it come from??)
- after 200ms, enhanced error is used (escaped)
I pushed an alternative fix, I'm not 100% sure of what I'm doing. It seems like on HMR upgrade, if any of the Vite processing thingy fails, Vite emits an error through the websocket that doesn't go through any of our usual error stuff. My method patches the .send method directly, but perhaps there's another way to do this properly? cc @bluwy I'll note that Vite lose a lot of information from errors when doing this, so trying to enhance might not even be relevant in the first place as we can't achieve much. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix looks good to me. Since any kind of errors can come through viteServer.hot.send()
, as long as we normalize it to escape HTML, or handle it in the overlay code, it should be fine.
Changes
Testing
Manual
Docs
N/A