Skip to content

Infinite recursion in NativeModules with Bun + Metro resolver (react-native -> uniwind/components loop) #352

Description

@eliotgevers

Environment:

  • bun 1.3.4
  • expo dev client (iOS)
  • uniwind 1.2.7
  • heroui-native 1.0.0-beta.12
  • Metro via withUniwindConfig
  • macOS + iOS simulator

Steps to reproduce:

  1. Enable Uniwind Metro resolver (withUniwindConfig)
  2. Import heroui-native (or any lib that touches NativeModules)
  3. Run dev client

Actual:

  • RangeError: Maximum call stack size exceeded
  • Stack shows repeated get NativeModules in Hermes bundle
  • App never registers main

Root cause:
Uniwind resolver rewrites react-native -> uniwind/components. Inside uniwind/components, it calls require("react-native"), which gets rewritten again when uniwind is not detected as internal under Bun's node_modules layout. This creates an infinite loop.

Workaround:
Bypass Uniwind resolver when origin is inside node_modules/uniwind (so internal requires use real react-native).

Expected fix:
Treat uniwind internals as internal even with symlinked node_modules (realpath or package-name check), so internal require("react-native") doesn't get rewritten.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions