Skip to content
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

Main world injection: Don't serialize results/errors #1534

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

marcustyphoon
Copy link
Collaborator

@marcustyphoon marcustyphoon commented Jul 2, 2024

Description

As noted in #1466 (comment), Firefox—for whatever reason—gives a useless "uncaught exception: Object" message if you throw an object in an async function, and we currently throw objects out of injected functions due to the need to serialize them to JSON.

Fun fact, however: we don't need to serialize them to JSON. CustomEvents support sending any StructuredClone-able value in Chromium, and Firefox... *mumble mumble xray vision mumble*.

This PR therefore removes the serialization step entirely, resulting in a native Error object being used here (still no stack, like Chromium has, but, progress):

Oddly, I'm not observing the cloneInto() call I needed to make this work in Firefox in 1052f23 (#1284) being necessary, when testing this current code in Firefox 126. I don't know whether this is due to MV3, due to a change in Firefox, or both. Therefore, big caveat: merging this PR without would require us to confirm that cloneInto() is not required in any Firefox version we support.

Not well-tested at time of writing. I would like to see if this works on Response objects.

Testing steps

@marcustyphoon marcustyphoon changed the title Main world injection: Don't stringify results/errors Main world injection: Don't serialize results/errors Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant