Metro resolver loop with react-native-worklets bundle mode: "Maximum call stack size exceeded" on launch (`get NativeModules`)
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, react-native
- 領域
- build-system, mobile
調査の方向性
The loop involves two Metro resolvers: nativeResolver in react-native-css, which handles react-native imports from internal origins, and the worklets bundle-mode shim at react-native-worklets/bundleMode/shims/reactNativeShim.js. Start by reading how nativeResolver delegates to the parent resolver for internal origins, then trace the cycle through react-native-css/dist/commonjs/components/index.cjs. Done means the reproduction in the issue no longer overflows the stack when both wrappers are applied, in either order, and the workaround in the issue is no longer needed.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
With react-native-worklets' bundle mode enabled (getBundleModeMetroConfig), the app crashes on launch, before AppRegistry registers anything:
RangeError: Maximum call stack size exceeded (native stack depth)
Invariant Violation: "main" has not been registered.
The stack is get NativeModules repeated, from the lazy getters in react-native-css/dist/commonjs/components/index.cjs.
Cause
Two Metro resolvers both rewrite react-native, and react-native-css hands its own react-native imports to the resolver below it:
- App code imports
react-native. Worklets bundle mode resolves it toreact-native-worklets/bundleMode/shims/reactNativeShim.js. - The shim runs
module.exports = require('react-native'). react-native-css'snativeResolverredirects that toreact-native-css/components. react-native-css/components/index.cjsimportsreact-native. Because the origin is internal,nativeResolverreturns the parent resolver's result, and the parent (worklets) sends it back to the shim.- The shim's exports are the react-native-css components, whose getters call
require('react-native'), which returns the shim again. The getters recurse forever.
It loops whichever order the two configs are applied in. nativeResolver already exempts react-native/index.js as an origin. The internal-origin path has a similar problem: it trusts the parent resolver to return the real package.
Workaround (in metro.config.js, after both wrappers):
const path = require('node:path');
const reactNativeCssDir = `${path.sep}node_modules${path.sep}react-native-css${path.sep}`;
const resolveRequest = config.resolver.resolveRequest;
config.resolver.resolveRequest = (context, moduleName, platform) =>
moduleName === 'react-native' &&
context.originModulePath.includes(reactNativeCssDir)
? context.resolveRequest(context, moduleName, platform)
: resolveRequest(context, moduleName, platform);
Suggested fix: in nativeResolver, resolve react-native from an internal origin with Metro's default context.resolveRequest instead of the parent resolver. react-native-css's components always need the real package.
Reproduction
npx rn-new@next --nativewind, add react-native-worklets, then in metro.config.js:
const { getDefaultConfig } = require('expo/metro-config');
const { withNativewind } = require('nativewind/metro');
const { getBundleModeMetroConfig } = require('react-native-worklets/bundleMode');
let config = getDefaultConfig(__dirname);
config = withNativewind(config);
config = getBundleModeMetroConfig(config);
module.exports = config;
Launch on iOS. The crash happens during module init, before any component renders.
Versions
- nativewind 5.0.0-rc.0
- react-native-css 3.1.0-rc.0
- react-native-worklets 0.13.0 (react-native-reanimated 4.7.1)
- react-native 0.86.3, expo 57.0.27
- tailwindcss 4.3.3
- iOS simulator, Hermes
Possibly related: #455 has the same error text, but a different trigger (styled() around react-native-svg at render time).
- 主要言語
- TypeScript
- スター
- 166
- フォーク
- 45
- 平均マージ
- 13日 14時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nativewind/react-native-css のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nativewind/react-native-css#545 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nativewind/react-native-css#544 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nativewind/react-native-css#543 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
nativewind/react-native-css#540 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nativewind/react-native-css#538 ·
メンテナーはふだん 3 日以内に返信
nativewind/react-native-css の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
lichess-org/lila#22324 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Feature Request] [Web] Expose kvCacheQuantizationBits in the onnxruntime-web WebGPU EP optionsオープンep:WebGPU platform:web quantization
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
microsoft/onnxruntime#33752 ·
メンテナーはふだん 2 日以内に返信
-
[Skill Bug]: entra-agent-id: inaccurate blueprint permission inheritance and parent token sub claimオープンbug entra-agent-id
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/GitHub-Copilot-for-Azure#3467 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
fix(worker): keep normal prepare waiting states failure-free対応中かも @LichKing-2234 が今日担当しました。 オープンagent:codex priority:P1
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
AgoraIO-Extensions/agent-infra#3745 ·
メンテナーはふだん 1 日以内に返信
-
The five-line work window can drop its oldest line: the per-line byte share ignores the JSON framing対応中かも @Eapp1e が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
makecindy/cindy#7973 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信