Skip to content

fix: broken error handling in Firefox#88

Merged
emensch merged 7 commits intomainfrom
ff-error-fix
Mar 2, 2026
Merged

fix: broken error handling in Firefox#88
emensch merged 7 commits intomainfrom
ff-error-fix

Conversation

@emensch
Copy link
Contributor

@emensch emensch commented Feb 27, 2026

Due to some mysterious behavior (likely in wasm-bindgen), JsErrors were not being thrown properly by wasm-bindgen generated functions.

As a workaround, we instead report our errors as JsStrings, which we then "convert" into Error objects at the boundary between JS/WASM.

I certainly do not love this as a fix. I am hopeful that the underlying issue in wasm-bindgen will eventually be fixed. See: wasm-bindgen/wasm-bindgen#4961

Additionally, this PR adds Firefox and Webkit to the test runner.

@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2026

🦋 Changeset detected

Latest commit: df4c3f5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@contentauth/c2pa-wasm Patch
@contentauth/c2pa-web Patch

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

Copy link
Contributor

@ale-adobe ale-adobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a Rust expert, so won't comment on any language-specific things. Overall short-term workaround fix looks good to me. Have some non-blocking comments and suggestions. Thanks for the fix!

Comment on lines +66 to +68
{ browser: 'chromium' },
{ browser: 'firefox' },
{ browser: 'webkit' }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

{
"singleQuote": true
"singleQuote": true,
"trailingComma": "none"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the linter should do this already, but I suppose it doesn't hurt to also have it configured for Prettier.

*
* I hope that one day this can be removed :)
*/
function wrapFunctions<T extends Record<string, (...args: any[]) => any>>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: alternate naming suggestion

Suggested change
function wrapFunctions<T extends Record<string, (...args: any[]) => any>>(
function wrapFunctionsForErrorHandling<T extends Record<string, (...args: any[]) => any>>(

* prevents the proper handling of Error objects. As a workaround, we throw strings from our wasm-bindgen
* functions and convert them into errors here.
*
* I hope that one day this can be removed :)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Prefer to leave commentary like this out of the actual function docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

/**
* Wraps all functions with additional error-handling code that converts any thrown strings into Error objects.
* This is only necessary because a bug (likely in wasm-bindgen, see https://github.com/wasm-bindgen/wasm-bindgen/issues/4961)
* prevents the proper handling of Error objects. As a workaround, we throw strings from our wasm-bindgen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* prevents the proper handling of Error objects. As a workaround, we throw strings from our wasm-bindgen
* prevents the proper handling of Error objects. As a workaround, we "throw" strings from our wasm-bindgen

Copy link
Contributor

@ale-adobe ale-adobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Firefox skip LGTM. Thanks!

@emensch emensch merged commit 62ba0d7 into main Mar 2, 2026
2 checks passed
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.

2 participants