Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Metro resolver recursion when separated uniwind instances are installed #353

Closed
Labels
bugSomething isn't working uniwind-oss

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/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

  1. Clone the repo below
  2. bun install
  3. bun expo run:ios
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working uniwind-oss

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /