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

Promise.allSettled is still undefined in 0.70.6 on iOS and Android with Hermes #35363

Closed
Elolawyn opened this issue Nov 16, 2022 · 8 comments
Closed
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@Elolawyn
Copy link

Elolawyn commented Nov 16, 2022

Description

Promise.allSettled is still undefined on iOS and Android with Hermes when you have installed both latests versions of react native and expo (on a bare react native project).

It seems to work fine when executing tests with jest, however.

yarn why v1.22.19
[1/4] 🤔  Why do we have the module "promise"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "promise@8.3.0"
info Reasons this module exists
   - "react-native" depends on it
   - Hoisted from "react-native#promise"
info Disk size without dependencies: "244KB"
info Disk size with unique dependencies: "296KB"
info Disk size with transitive dependencies: "296KB"
info Number of shared dependencies: 1
=> Found "fbjs#promise@7.3.1"
info This module exists because "expo#fbemitter#fbjs" depends on it.
info Disk size without dependencies: "220KB"
info Disk size with unique dependencies: "272KB"
info Disk size with transitive dependencies: "272KB"
info Number of shared dependencies: 1
✨  Done in 0.25s.

Version

0.70.6

Output of npx react-native info

info Fetching system and libraries information...
System:
    OS: macOS 12.6
    CPU: (10) arm64 Apple M1 Pro
    Memory: 658.97 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.asdf/installs/nodejs/16.16.0/bin/node
    Yarn: 1.22.19 - ~/.asdf/installs/nodejs/16.16.0/bin/yarn
    npm: 8.11.0 - ~/.asdf/plugins/nodejs/shims/npm
    Watchman: 2022.09.19.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /Users/rarroyo/.asdf/shims/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9014738
    Xcode: 14.1/14B47b - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.16.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.70.6 => 0.70.6
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

1.- Have react native 0.70.6 installed.
2.- Have expo installed on a bare react native application following their documentation.
3.- Use Promise.allSettled.
4.- Get [TypeError: undefined is not a function].

Snack, code example, screenshot, or link to a repository

const results = await Promise.allSettled([promise1, promise2])
@Elolawyn Elolawyn changed the title Promise.allSettled is still undefined in 0.70.6 on iOS and Android Promise.allSettled is still undefined in 0.70.6 on iOS and Android with Hermes Nov 16, 2022
@jkadamczyk
Copy link

I have to agree with the issue. My setup is slightly different. I use 0.68.5 in a project, along with hermes-engine version 0.11.0.
It should've been fixed in 0.68.4, which makes me assume that it should also work in 0.68.5, but it doesn't work.

@retyui
Copy link
Contributor

retyui commented Dec 2, 2022

promise@8.3.0 will be used for a JSC engine or jest environment, as I understand the latest Hermes has own implementation of Promise

see:

// If global.Promise is provided by Hermes, we are confident that it can provide
// all the methods needed by React Native, so we can directly use it.
if (global?.HermesInternal?.hasPromise?.()) {
const HermesPromise = global.Promise;
if (__DEV__) {
if (typeof HermesPromise !== 'function') {
console.error('HermesPromise does not exist');
}
global.HermesInternal?.enablePromiseRejectionTracker?.(
require('../promiseRejectionTrackingOptions').default,
);
}
} else {
polyfillGlobal('Promise', () => require('../Promise'));

to test:

console.log(' --- debug',{allSettled:Promise.allSettled,any:Promise.any, hermes_hasPromise:global?.HermesInternal?.hasPromise?.()})

 --- debug {"allSettled": undefined, "any": undefined, "hermes_hasPromise": true}

So, better to create issue in an appropriate repo

@github-actions
Copy link

github-actions bot commented Jun 1, 2023

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jun 1, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

@BrandonYuen
Copy link

This still seems to be an issue for me on 0.71.8, when using the exact example from mozilla docs:

Promise.allSettled([
  Promise.resolve(33),
  new Promise((resolve) => setTimeout(() => resolve(66), 0)),
  99,
  Promise.reject(new Error("an error")),
]).then((values) => console.log(values));

It seems to never log any values and only shows me this warning:

Possible Unhandled Promise Rejection (id: 3):
Error: an error

@cesargdm
Copy link

Appears to still be an issue in 0.72.6

@oidoug
Copy link

oidoug commented Dec 7, 2023

I'm getting loads of issue reports on Sentry for TypeError: undefined is not a function when calling Promise.allSettled(promises)

All issues are on Android and Hermes for RN 0.72.4.
But I can't replicate on the devices I have at hand, really weird.

@MohammadAzimi
Copy link

I'm using "expo": "~49.0.6" and "react-native": "0.72.6" and the issue is remaining only in production.
I found a temporary workaround in here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

7 participants