fix: resolve var hoisting bug in console bridge#1494
Open
Conversation
…hidden The console bridge had a critical bug where the 'seen' Set was used in the JSON.stringify replacer function before it was declared. Due to JavaScript var hoisting, 'seen' was undefined when accessed, causing TypeError that were caught and swallowed, hiding actual errors from the frame code. This fix moves the 'seen' declaration to before the try block where it's used, ensuring it's properly initialized. This will allow actual errors from attestation verification and other frame operations to be properly logged and visible for debugging. Impact: This bug was hiding 'Load failed' and other critical errors in WKWebView environments, making it impossible to diagnose attestation verification failures. Co-Authored-By: austin@paella.dev <austin@paella.dev>
Contributor
Original prompt from austin@paella.dev |
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
🦋 Changeset detectedLatest commit: e0946dc The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
Co-Authored-By: austin@paella.dev <austin@paella.dev>
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.
Description
Fixes a critical JavaScript var hoisting bug in the React Native WebView console bridge that was hiding errors from the frame code.
The Problem:
The
seenSet variable was declared inside afinallyblock usingvar, but was accessed in thetryblock's JSON.stringify replacer function. Due to JavaScript var hoisting,seenwasundefinedwhen accessed, causingTypeError: Cannot read property 'has' of undefined. This error was caught and swallowed, returning'[Unserializable Object]'instead of the actual error message.The Impact:
This bug was hiding critical errors from the open-signer frame code running in WKWebView, including:
This made debugging WKWebView issues nearly impossible, as reported in https://crossmint.slack.com/archives/C09T6V4QSEQ/p1763238997415029.
The Fix:
seendeclaration to before thetryblock where it's usedvartoconstfor proper scopingvar seendeclarationTest plan
Unit tests should be added for the console bridge serialization logic in a follow-up.
Package updates
@crossmint/client-sdk-rn-window- patch version bump neededpnpm change:addto create changesetHuman Review Checklist:
Requested by: austin@paella.dev (@afeight)
Devin session: https://app.devin.ai/sessions/019ddb2501804c8d83765e0311cb6720