facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.69k stars 620 forks source link

Promise.allSettled undefined on iOS and Android using Hermes #1476

Closed ammar-madni closed 1 month ago

ammar-madni commented 1 month ago

Description

Our Sentry logs are showing multiple error events when calling Promise.allSettled with the error being undefined is not a function.

I can't replicate the issue locally, only seems to happen in production.

https://github.com/facebook/react-native/issues/35363

Steps to reproduce

1.- Setup a blank react native app. 2.- Use Promise.allSettled. 3.- Build the app for production. 4.- Get [TypeError: undefined is not a function].

React Native Version

0.74.5

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.5
  CPU: (10) arm64 Apple M1 Max
  Memory: 111.30 MB / 64.00 GB
  Shell: Unknown
Binaries:
  Node:
    version: 18.20.3
    path: ~/.local/state/fnm_multishells/91817_1721590401131/bin/node
  Yarn:
    version: 1.22.19
    path: /usr/local/bin/yarn
  npm:
    version: 10.7.0
    path: ~/.local/state/fnm_multishells/91817_1721590401131/bin/npm
  Watchman:
    version: 2024.05.06.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2411.12071903
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.5
    wanted: 0.74.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

TypeError: undefined is not a function
  at refetchAll(/src/app/bookings/[id]/edit.tsx:103:34)
  at fetchData(/src/utils/hooks/useUserInitiatedFetch.ts:9:20)
  at next(native)
  at asyncGeneratorStep(/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:17)
  at _next(/node_modules/@babel/runtime/helpers/asyncToGenerator.js:17:27)
  at Promise$argument_0(/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:12)
  at tryCallTwo(/node_modules/promise/setimmediate/core.js:45:7)
  at doResolve(/node_modules/promise/setimmediate/core.js:200:23)
  at Promise(/node_modules/promise/setimmediate/core.js:66:12)
  at <anonymous>(/node_modules/@babel/runtime/helpers/asyncToGenerator.js:14:23)
  at _onRefresh(/node_modules/react-native/Libraries/Components/RefreshControl/RefreshControl.js:187:49)
  at apply(native)
  at invokeGuardedCallbackImpl(/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:22:15)
  at apply(native)
  at invokeGuardedCallback(/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:40:34)
  at apply(native)
  at invokeGuardedCallbackAndCatchFirstError(/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:53:30)
  at executeDispatch(/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:73:42)
  at executeDispatchesAndReleaseTopLevel(/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1047:24)
  at call(native)
  at forEachAccumulated(/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:364:63)
  at batchedUpdates$1$argument_0(/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1082:25)
  at batchedUpdatesImpl(/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:9578:14)
  at batchedUpdates$1(/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1028:30)
  at _receiveRootNodeIDEvent(/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1059:19)
  at ReactNativePrivateInterface.RCTEventEmitter.register$argument_0.receiveEvent(/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1102:28)
  at apply(native)
  at __callFunction(/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:433:34)
  at __guard$argument_0(/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:113:26)
  at __guard(/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:368:11)
  at callFunctionReturnFlushedQueue(/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:112:17)

Reproducer

https://github.com/ammar-madni/promise-all-settled-undefined

Screenshots and Videos

Screenshot 2024-08-16 at 10 02 10
cortinico commented 1 month ago

Passing over to the hermes team

tmikov commented 1 month ago

Hi, we are unable to investigate problems without a minimal repro, plus this doesn't look like a bug in Hermes - Hermes exposes Promise.allSettled().

However from a cursory glance it looks like you are using a Promise polyfill, not the Promise provided by Hermes, judging by the following lines in your stack trace:

  at tryCallTwo(/node_modules/promise/setimmediate/core.js:45:7)
  at doResolve(/node_modules/promise/setimmediate/core.js:200:23)
  at Promise(/node_modules/promise/setimmediate/core.js:66:12)