Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/four-olives-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@crossmint/client-sdk-rn-window": patch
---

Fix var hoisting bug in console bridge that was hiding errors from frame code
5 changes: 1 addition & 4 deletions packages/client/rn-window/src/rn-webview/RNWebView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const INJECTED_BRIDGE_JS = `
return '[Function]';
}
if (typeof arg === 'object' && arg !== null) {
const seen = new Set(); // Declare before use to avoid hoisting issues
try {
// Use a replacer function to handle potential circular references
return JSON.stringify(arg, (key, value) => {
Expand All @@ -45,14 +46,10 @@ const INJECTED_BRIDGE_JS = `
}, 2); // Optional: pretty print JSON
} catch (e) {
return '[Unserializable Object]';
} finally {
// Clean up seen set after stringifying each top-level argument
var seen = new Set(); // Use var for function scope before ES6 modules
}
}
return String(arg); // Convert primitive types to string directly
});
var seen = new Set(); // Declare seen here for the final stringify
const message = JSON.stringify({ type: 'console.' + type, data: serializedArgs });
if (window.ReactNativeWebView && typeof window.ReactNativeWebView.postMessage === 'function') {
window.ReactNativeWebView.postMessage(message);
Expand Down