I'm encountering a crash in my React Native app. The crash report from Crashlytics indicates an unhandled JavaScript exception with the following error:
Fatal Exception: RCTFatalException: Unhandled JS Exception: TypeError: Restricted in strict mode, js engine: hermes
0 CoreFoundation 0x827cc __exceptionPreprocess
1 libobjc.A.dylib 0x172e4 objc_exception_throw
2 MyApp 0x38a764 RCTFormatError + 167 (RCTAssert.m:167)
3 MyApp 0x3f9354 -[RCTExceptionsManager reportFatal:stack:exceptionId:extraDataAsJSON:] + 82 (RCTExceptionsManager.mm:82)
4 MyApp 0x3f9b74 -[RCTExceptionsManager reportException:] + 154 (RCTExceptionsManager.mm:154)
5 CoreFoundation 0x20374 __invoking___
6 CoreFoundation 0x1f3c4 -[NSInvocation invoke]
7 CoreFoundation 0x94cb8 -[NSInvocation invokeWithTarget:]
8 MyApp 0x3ba2c4 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 587 (RCTModuleMethod.mm:587)
9 MyApp 0x3bc33c facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&, int, (anonymous namespace)::SchedulingContext) + 197 (RCTNativeModule.mm:197)
10 MyApp 0x3bbf88 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 298 (optional:298)
11 libdispatch.dylib 0x2370 _dispatch_call_block_and_release
12 libdispatch.dylib 0x40d0 _dispatch_client_callout
13 libdispatch.dylib 0xb6d8 _dispatch_lane_serial_drain
14 libdispatch.dylib 0xc1e0 _dispatch_lane_invoke
15 libdispatch.dylib 0x17258 _dispatch_root_queue_drain_deferred_wlh
16 libdispatch.dylib 0x16aa4 _dispatch_workloop_worker_thread
17 libsystem_pthread.dylib 0x4c7c _pthread_wqthread
18 libsystem_pthread.dylib 0x1488 start_wqthread
I'm trying to determine the root cause but haven't found a clear explanation yet. Here are some details about my setup and what I've tried so far:
- React Native Version: 0.72.6
- Crash Context: The crash is reported on Crashlytics in production after and update and I have not been able to reproduce it consistently during development.
- Error Detail: The error message states "Restricted in strict mode". I suspect this may be related to some JavaScript code that is violating strict mode restrictions, but I'm not sure which part of the code might be causing it.
- Investigation: I've searched for similar issues with the Hermes engine and strict mode, but haven't found a definitive answer or reproduction scenario.
Questions:
- What could cause the "TypeError: Restricted in strict mode" error in a React Native app using Hermes? Are there known pitfalls or common coding mistakes (or library issues) that trigger this error?
- What debugging strategies or tools can I use to isolate the problematic code since the error only appears in production?
Any insights, similar experiences, or suggestions on how to track down this issue would be greatly appreciated!