Metro resolver loop with react-native-worklets bundle mode: "Maximum call stack size exceeded" on launch (`get NativeModules`)
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 30/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, react-native
- Área
- build-system, mobile
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
- Lenguaje dominante
- TypeScript
- Estrellas
- 166
- Forks
- 45
- Merge medio
- 13 d 14 h
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nativewind/react-native-css
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nativewind/react-native-css#545 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nativewind/react-native-css#544 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nativewind/react-native-css#543 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
nativewind/react-native-css#540 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nativewind/react-native-css#538 ·
Los mantenedores suelen responder en 3 días
Todos los issues de nativewind/react-native-css
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
lichess-org/lila#22324 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Feature Request] [Web] Expose kvCacheQuantizationBits in the onnxruntime-web WebGPU EP optionsAbiertoep:WebGPU platform:web quantization
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
microsoft/onnxruntime#33752 ·
Los mantenedores suelen responder en 2 días
-
[Skill Bug]: entra-agent-id: inaccurate blueprint permission inheritance and parent token sub claimAbiertobug entra-agent-id
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/GitHub-Copilot-for-Azure#3467 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
fix(worker): keep normal prepare waiting states failure-freePosiblemente ocupada @LichKing-2234 la tomó hoy. Abiertoagent:codex priority:P1
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
AgoraIO-Extensions/agent-infra#3745 ·
Los mantenedores suelen responder en 1 día
-
The five-line work window can drop its oldest line: the per-line byte share ignores the JSON framingPosiblemente ocupada @Eapp1e la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
makecindy/cindy#7973 · 1 comentario ·
Los mantenedores suelen responder en 1 día