Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

SyntaxError: JSON Parse error: Unexpected identifier "setImmediate$0" #56

Open
cloudpresser opened this issue Sep 13, 2021 · 1 comment

Comments

@cloudpresser
Copy link

cloudpresser commented Sep 13, 2021

When the WebView loads, it throws the error:

SyntaxError: JSON Parse error: Unexpected identifier "setImmediate$0"
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:9:32 in ErrorUtils.setGlobalHandler$argument_0
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue

It seems like the error is cause because the plaid link page is running window.postMessage with a string containing setImmediate$0 which is then passed to JSON.parse(e.nativeEvent.data), and since it is not valid JSON, it throws the error.

@cloudpresser
Copy link
Author

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-plaid-link/index.js b/node_modules/react-native-plaid-link/index.js
index 4a4013e..90d423c 100644
--- a/node_modules/react-native-plaid-link/index.js
+++ b/node_modules/react-native-plaid-link/index.js
@@ -82,8 +82,11 @@ class PlaidAuthenticator extends Component {
         }
       }
     */
-
-    this.props.onMessage(JSON.parse(e.nativeEvent.data));
+    try {
+        this.props.onMessage(JSON.parse(e.nativeEvent.data));
+    } catch (err) {
+      this.props.onMessage(e.nativeEvent.data)
+    }
   };
 }
 

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant