facebook / react-native

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

HeadlessTask: Could not enqueue microtask because they are disabled in this runtime #47570

Open mbpictures opened 1 day ago

mbpictures commented 1 day ago

Description

I'm using react-native-firebase messaging to receive firebase push notifications using this line:

messaging().setBackgroundMessageHandler(onMessageReceived);

However the App Crashes with this error:

Error: Exception in HostFunction: Could not enqueue microtask because they are disabled in this runtime, js engine: hermes

The symbolicated stacktrace looks like this:

node_modules/react-native/Libraries/Core/Timers/immediateShim.js:44:setImmediate
node_modules/react-native/Libraries/ReactNative/AppRegistry.js:307:startHeadlessTask
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:434:__callFunction
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:113:__guard$argument_0
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:368:__guard
react-native/Libraries/BatchedBridge/MessageQueue.js:112:callFunctionReturnFlushedQueue

Steps to reproduce

  1. Setup react native 0.76.1 project
  2. Install and setup react-native-firebase/messaging
  3. Add Background Message Handler
  4. Build for release and test on device

React Native Version

0.76.1

Affected Platforms

Runtime - Android

Areas

Bridgeless - The New Initialization Flow

Output of npx react-native info

System:
  OS: Windows 11 10.0.22631
  CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K
  Memory: 3.65 GB / 31.78 GB
Binaries:
  Node:
    version: 20.10.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 4.4.1
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 8.12.2
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowAllTrustedApps: Enabled
    AllowDevelopmentWithoutDevLicense: Enabled
    Versions:
      - 10.0.19041.0
      - 10.0.22000.0
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 16.11.35026.282 (Visual Studio Community 2019)
    - 17.10.35122.118 (Visual Studio Community 2022)
Languages:
  Java:
    version: 17.0.9
    path: /cygdrive/c/Program Files/Microsoft/jdk-17.0.9.8-hotspot/bin/javac
  Ruby:
    version: 3.2.3
    path: C:\Ruby32-x64\bin\ruby.EXE
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.0
    wanted: 15.0.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.1
    wanted: 0.76.1
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

Error: Exception in HostFunction: Could not enqueue microtask because they are disabled in this runtime, js engine: hermesFATAL EXCEPTION: mqt_native_modules
Process: , PID: 24014
    com.facebook.react.common.JavascriptException: Error: Exception in HostFunction: Could not enqueue microtask because they are disabled in this runtime, js engine: hermes, stack:
     setImmediate@1:338517
     startHeadlessTask@1:392921
     __callFunction@1:192422
     anonymous@1:190722
     __guard@1:191681
     callFunctionReturnFlushedQueue@1:190680

at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(SourceFile:77)
at com.facebook.jni.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(SourceFile:1)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at  com.facebook.react.bridge.queue.MessageQueueThreadImpl.lambda$startNewBackgroundThread$2(SourceFile:36)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.b(SourceFile:1)
at com.facebook.react.bridge.queue.b.run(SourceFile:1)  
at java.lang.Thread.run(Thread.java:1012)

Reproducer

mbpictures/react-native-microtask-repro

Screenshots and Videos

No response

react-native-bot commented 1 day ago

[!WARNING] Missing reproducer: We could not detect a reproducible example in your issue report. Please provide either:

shubhamguptadream11 commented 16 hours ago

It will be helpful if you provide a repro as well. You can use this template.

mbpictures commented 11 hours ago

Repro added in issue description