facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
116.89k stars 24.05k forks source link

Error on reload: ERROR Invariant Violation: Failed to call into JavaScript module method RCTEventEmitter.receiveEvent().. #42640

Open skinnynpale opened 5 months ago

skinnynpale commented 5 months ago

Description

if you reload the application from the simulator (using the hot button), we get the following error, if you reload the application from the metro bundler, then there is no such error

ERROR Invariant Violation: Failed to call into JavaScript module method RCTEventEmitter.receiveEvent(). Module has not been registered as callable. Bridgeless Mode: false. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, HMRClient, AppRegistry. A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes

Steps to reproduce

if you reload the application from the simulator (using the hot button), we get the following error, if you reload the application from the metro bundler, then there is no such error

React Native Version

0.73.2

Affected Platforms

Runtime - iOS

Areas

Fabric - The New Renderer, TurboModule - The New Native Module System, JSI - Javascript Interface, Bridgeless - The New Initialization Flow, Codegen

Output of npx react-native info

System:
  OS: macOS 14.2.1
  CPU: (12) arm64 Apple M3 Pro
  Memory: 104.56 MB / 18.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.19.0
    path: ~/.nvm/versions/node/v18.19.0/bin/node
  Yarn:
    version: 1.22.21
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.3
    path: ~/.nvm/versions/node/v18.19.0/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/skinnynpale/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11076708
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 3.0.6
    path: /Users/skinnynpale/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.2
    wanted: 0.73.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

ERROR  Invariant Violation: Failed to call into JavaScript module method RCTEventEmitter.receiveEvent(). Module has not been registered as callable. Bridgeless Mode: false. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, HMRClient, AppRegistry.          A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes

Reproducer

--

Screenshots and Videos

telegram-cloud-photo-size-2-5298888882256991998-w

github-actions[bot] commented 5 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
cortinico commented 5 months ago

if you reload the application from the simulator (using the hot button)

What do you mean with the "hot button" in the simulator?

skinnynpale commented 5 months ago

if you reload the application from the simulator (using the hot button)

What do you mean with the "hot button" in the simulator?

when I press "R" while in the application, the metro bundler reload is triggered

cortinico commented 5 months ago

I've tested this on RN Tester, and the problem doesn't happen. @skinnynpale are you able to create a reproducer of any sort? I suppose this could be related to some 3rd party library you have included.

skinnynpale commented 5 months ago

I've tested this on RN Tester, and the problem doesn't happen. @skinnynpale are you able to create a reproducer of any sort? I suppose this could be related to some 3rd party library you have included.

Okay, thank you! I'll try

RSNara commented 5 months ago

@skinnynpale, are you running into this issue in Bridgeless mode?

Fabric - The New Renderer, TurboModule - The New Native Module System, JSI - Javascript Interface, Bridgeless - The New Initialization Flow, Codegen

This code should never run in Bridgeless mode! I think you've stumbled onto an interesting bug. Looking forward to the reproducer!

skinnynpale commented 5 months ago

@skinnynpale, are you running into this issue in Bridgeless mode?

Fabric - The New Renderer, TurboModule - The New Native Module System, JSI - Javascript Interface, Bridgeless - The New Initialization Flow, Codegen

This code should never run in Bridgeless mode! I think you've stumbled onto an interesting bug. Looking forward to the reproducer!

Research has shown that this error is triggered by createStackNavigator. We are thinking about switching to a native stack.

skinnynpale commented 5 months ago

@skinnynpale, are you running into this issue in Bridgeless mode?

Fabric - The New Renderer, TurboModule - The New Native Module System, JSI - Javascript Interface, Bridgeless - The New Initialization Flow, Codegen

This code should never run in Bridgeless mode! I think you've stumbled onto an interesting bug. Looking forward to the reproducer!

I'm sorry, we don't have Bridgeless enabled, I thought it was enabled by default in the new architecture

cortinico commented 5 months ago

we don't have Bridgeless enabled, I thought it was enabled by default in the new architecture

Nope it needs to be enabled separately in 0.73 @skinnynpale are you able to create a repro in any form?

sbin1211 commented 5 months ago

we don't have Bridgeless enabled, I thought it was enabled by default in the new architecture

Nope it needs to be enabled separately in 0.73 @skinnynpale are you able to create a repro in any form?

@cortinico it caused by the react-native-screens with @react-navigation/bottom-tabs,

you can reproduce this issue with below repro. (when you trigger the "reload" inside app, the error happen, but NOT from terminal

https://github.com/sbin1211/RNInvariantViolation.git

cortinico commented 5 months ago

it caused by the react-native-screens with @react-navigation/bottom-tabs,

Great, can we open an issue against react-native-screens and link it here?

sbin1211 commented 4 months ago

it caused by the react-native-screens with @react-navigation/bottom-tabs,

Great, can we open an issue against react-native-screens and link it here?

sure. @cortinico please help to link it. i don't know which side (RN or RNScreens) cause this issue.

cortinico commented 4 months ago

sure. @cortinico please help to link it.

Please create the issue there, and post it here afterwards