fix: stop devtools exceptions from unwinding into the inspected app - #210
Merged
Conversation
Follow-up to #209, which fixed one poison value (invalid Date) but not the boundary that lets a poison value reach the host app. sync.content.ts runs in the page's MAIN world and QueryCache.notify iterates its subscribers without catching, so anything thrown in a subscriber unwinds into the inspected application's own render/commit and trips its error boundary, with a stack trace that gives no hint an extension is involved. Invalid Date was one instance; objects with throwing getters, hostile Proxies and Object.create(Date.prototype) still reach the same path. - guard every callback the page can invoke (both cache subscribers, the initial snapshot, the panel message handler, the detection poll) so a serialization failure skips one devtools update instead of breaking the page - isInvalidDate: read [[DateValue]] via Date.prototype.getTime.call instead of the overridable date.getTime(), so the guard agrees with the toISOString it protects. An overridden getTime could otherwise hide a NaN time value, or throw where the unguarded code did not - serializeToJsLiteral: run the emitted date through escapeString like every other string in that function. toISOString is page-overridable and this output goes to the user's clipboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #209, which fixed one poison value (invalid Date) but not the
boundary that lets a poison value reach the host app.
sync.content.ts runs in the page's MAIN world and QueryCache.notify iterates
its subscribers without catching, so anything thrown in a subscriber unwinds
into the inspected application's own render/commit and trips its error
boundary, with a stack trace that gives no hint an extension is involved.
Invalid Date was one instance; objects with throwing getters, hostile Proxies
and Object.create(Date.prototype) still reach the same path.
initial snapshot, the panel message handler, the detection poll) so a
serialization failure skips one devtools update instead of breaking the page
the overridable date.getTime(), so the guard agrees with the toISOString it
protects. An overridden getTime could otherwise hide a NaN time value, or
throw where the unguarded code did not
other string in that function. toISOString is page-overridable and this
output goes to the user's clipboard