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/components for most modules.
- Inside
uniwind/components, many getters call require(\"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/...
but cachedInternalBasePath is:
.../node_modules/uniwind/dist/module
- That mismatch makes
isInternal false → rewrite loop.
Suggested fix:
- Normalize paths with
realpathSync (or equivalent) for both cachedInternalBasePath and originModulePath, or
- Use a package-boundary check (e.g.
/node_modules/uniwind/) instead of a raw startsWith on a non-normalized path.
Steps to Reproduce
- Clone the repo below
bun install
bun 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
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:
Findings / root cause hypothesis:
require(\"react-native\")→uniwind/componentsfor most modules.uniwind/components, many getters callrequire(\"react-native\")again (to access NativeModules, etc).context.originModulePath.startsWith(cachedInternalBasePath).../node_modules/.bun/uniwind@1.2.7/node_modules/uniwind/dist/module/components/...but
cachedInternalBasePathis:.../node_modules/uniwind/dist/moduleisInternalfalse → rewrite loop.Suggested fix:
realpathSync(or equivalent) for bothcachedInternalBasePathandoriginModulePath, or/node_modules/uniwind/) instead of a rawstartsWithon a non-normalized path.Steps to Reproduce
bun installbun expo run:iosNote: 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