Bundle Mode startup recurses when Uniwind remaps React Native
Description
[!NOTE] This issue was authored by AI on behalf of @eliotgevers.
With Worklets Bundle Mode and Uniwind enabled, a native Expo app crashes before rendering:
[runtime not ready]: RangeError: Maximum call stack size exceeded (native stack depth)The Bundle Mode React Native shim calls require('react-native'). Uniwind redirects that request to its component wrapper, whose React Native imports resolve back to the Worklets shim. This creates a startup cycle. The app should render its styled screen and run worklets normally.
The proposed fix gives the shim an internal specifier resolved through Metro's default resolver, leaving app imports on the existing resolver chain. Related discussion and the original internal-specifier proposal: #9817.
Steps to reproduce
- Clone the reproduction below and run
bun install --frozen-lockfile. - Run
bun run iosorbun run androidwith a simulator/emulator available. The example uses the documented Bundle Mode Metro patches andwithUniwindConfig(getBundleModeMetroConfig(config), ...). - Observe the startup crash instead of the blue screen showing
Worklet result: 42. The README includes a two-file patch and commands for comparing the fix with a clean Metro cache.
Snack or a link to a repository
https://github.com/eliotgevers/worklets-uniwind-reproduction
Reanimated version
4.7.0
Worklets version
0.13.0
React Native version
0.88.0-rc.2
Platforms
Android, iOS
Additional information
Expo 58.0.0-preview.8, Uniwind 1.12.0, Hermes, New Architecture, native Debug builds on macOS. The shim's bare request is also still present on upstream main at 9f59e6c9.
Acknowledgements
Yes, I searched for similar issues. See #9817 above.
Source: software-mansion/react-native-reanimated