-
Notifications
You must be signed in to change notification settings - Fork 41
Metro resolver recursion when separated uniwind instances are installed #353
Closed
Description
What happened?
When running a dev build via bun expo run:ios, the app crashes with an infinite recursion in Uniwind’s Metro resolver. The error is a NativeModules stack overflow. This does not happen in Expo Go (same repo, same code).
Error signature:
[runtime not ready]: RangeError: Maximum call stack size exceeded (native stack depth)
get NativeModules
get NativeModules
...
Findings / root cause hypothesis:
- Uniwind rewrites
require(\"react-native\")→uniwind/componentsfor most modules. - Inside
uniwind/components, many getters callrequire(\"react-native\")again (to access NativeModules, etc). - If Uniwind fails to detect that the origin is inside Uniwind, it rewrites again → infinite loop.
- Guard currently uses:
context.originModulePath.startsWith(cachedInternalBasePath) - Under Bun, the path looks like:
.../node_modules/.bun/uniwind@1.2.7/node_modules/uniwind/dist/module/components/...
butcachedInternalBasePathis:
.../node_modules/uniwind/dist/module - That mismatch makes
isInternalfalse → rewrite loop.
Suggested fix:
- Normalize paths with
realpathSync(or equivalent) for bothcachedInternalBasePathandoriginModulePath, or - Use a package-boundary check (e.g.
/node_modules/uniwind/) instead of a rawstartsWithon a non-normalized path.
Steps to Reproduce
- Clone the repo below
bun installbun expo run:ios- Launch the dev build (crash occurs on startup)
Note: Expo Go does not crash.
Snack or Repository Link (Optional)
https://github.com/eliotgevers/uniwind-heroui-bun-repro
Uniwind version
1.2.7
React Native Version
0.81.5
Platforms
iOS
Expo
Yes
Additional information
- I've searched for similar issues in this repository and found none
- I am a Uniwind Pro user
Metadata
Metadata
Assignees
Type
Fields
Give feedbackNo fields configured for issues without a type.