Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Awais7899 opened this issue Jan 21, 2025 · 1 comment

Comments

@Awais7899
Copy link

Awais7899 commented Jan 21, 2025

After enabling the hermes on android getting this error

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

import messaging from '@react-native-firebase/messaging';
import notifee, {
  AndroidCategory,
  AndroidColor,
  AndroidImportance,
  AndroidVisibility,
} from '@notifee/react-native';
let notificationId = null; // Variable to hold the notification Id
let callerSocketId;
let notificationCancel = false;
let uuid = null;
export default messaging().setBackgroundMessageHandler(async remoteMessage => {
  // Retrieve notification type from data payload
  const notificationType = remoteMessage?.data?.type;
  // Handle different notification types
  switch (notificationType) {
    case 'call':
      await handleVideoCallNotification(remoteMessage);
      break;
    case 'event':
      await eventHandler(remoteMessage);
      break;
    default:
      console.log('Unhandled notification type:', notificationType);
  }
});
// Handle video call notification
async function handleVideoCallNotification(remoteMessage) {
  notificationCancel = false;
  const user = JSON.parse(remoteMessage?.data?.user);
  callerSocketId = JSON.parse(remoteMessage?.data?.socketId);
  const callerName = `${user?.first_name} ${user?.last_name}`;
  const channelId = await notifee.createChannel({
    id: 'video_call',
    name: 'video call',
    importance: AndroidImportance.HIGH,
    vibration: true,
    sound: 'teams',
  });
  notificationId = await notifee.displayNotification({
    title: 'Incoming call',
    body: `Call is coming from ${callerName}`,
    android: {
      channelId,
      category: AndroidCategory.CALL,
      visibility: AndroidVisibility.PUBLIC,
      importance: AndroidImportance.HIGH,
      timestamp: Date.now() + 30000,
      showChronometer: true,
      chronometerDirection: 'down',
      loopSound: true,
      sound: 'teams',
      showTimestamp: true,
      vibration: true,
      fullScreenAction: {
        id: 'default',
      },
      pressAction: {
        id: 'default',
        launchActivity: 'default',
      },
      actions: [
        {
          title: 'Open Helpsoeasy',
          pressAction: {
            id: 'open',
            launchActivity: 'default',
          },
        },
      ],
      timeoutAfter: 30000,
    },
  });
}
// Handle chat message notification
async function eventHandler(remoteMessage) {
  notificationCancel = true;
  if (notificationId !== null) {
    await notifee.cancelNotification(notificationId);
  }
}

npx react-native info

System:
  OS: macOS 15.0.1
  CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
  Memory: 186.98 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.18.1
    path: ~/.nvm/versions/node/v20.18.1/bin/node
  Yarn: Not Found
  npm:
    version: 10.8.2
    path: ~/.nvm/versions/node/v20.18.1/bin/npm
  Watchman:
    version: 2024.12.02.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.1
      - iOS 18.1
      - macOS 15.1
      - tvOS 18.1
      - visionOS 2.1
      - watchOS 11.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12700392
  Xcode:
    version: 16.1/16B40
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.4
    wanted: 0.75.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: false

"@notifee/react-native": "^9.1.8",

@mikehardy
Copy link
Collaborator

🤔

react-native installed: 0.75.4

"@notifee/react-native": "^9.1.8",

Surprised that happens with 9.1.8 as all the work here recently was to fix problems like that, and I'm certain I tested with Hermes.

I was definitely focused on testing with react-native 0.76 though, and new architecture. Have you attempted to upgrade to that and see if it goes away?

If it is still reproducible I'll need to see the device logs from a reproduction to see what sort of exception has been thrown. The exception you mention is a secondary sort of thing that unfortunately masks the real problem. The real problem is usually only visible in device logs (adb logcat for example) in my experience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants