aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.41k stars 2.12k forks source link

DataStore + Hermes = 💩 ([TypeError: Symbol.asyncIterator is not defined.]) #8176

Closed Darapsas closed 3 years ago

Darapsas commented 3 years ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

DataStore

Amplify Categories

auth, api

Environment information

``` # Put output below this line System: OS: macOS 10.15.7 CPU: (6) x64 Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz Memory: 647.25 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 16.0.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.10.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Browsers: Chrome: 88.0.4324.96 Firefox: 88.0 Safari: 14.0.3 npmPackages: @babel/core: ^7.12.9 => 7.13.16 (7.9.0) @babel/runtime: ^7.12.5 => 7.13.17 @react-native-async-storage/async-storage: ^1.15.3 => 1.15.3 @react-native-community/blur: ^3.6.0 => 3.6.0 @react-native-community/eslint-config: ^2.0.0 => 2.0.0 @react-native-community/geolocation: ^2.0.2 => 2.0.2 @react-native-community/masked-view: 0.1.10 => 0.1.10 @react-native-community/netinfo: ^6.0.0 => 6.0.0 @react-navigation/bottom-tabs: 5.11.9 => 5.11.9 @react-navigation/native: 5.9.4 => 5.9.4 @react-navigation/stack: 5.14.4 => 5.14.4 @svgr/cli: 5.5.0 => 5.5.0 @testing-library/jest-native: ^3.4.3 => 3.4.3 @testing-library/react-native: ^7.0.2 => 7.2.0 @types/color: ^3.0.1 => 3.0.1 @types/i18n-js: ^3.8.0 => 3.8.0 @types/jest: ^26.0.22 => 26.0.22 @types/lodash: ^4.14.168 => 4.14.168 @types/react: ^17.0.3 => 17.0.3 @types/react-native: ^0.64.2 => 0.64.4 @types/react-native-vector-icons: 6.4.6 => 6.4.6 @types/react-test-renderer: ^17.0.1 => 17.0.1 @types/yup: ^0.29.0 => 0.29.11 HelloWorld: 0.0.1 amazon-cognito-identity-js: 4.6.0 => 4.6.0 aws-amplify: 3.3.27 => 3.3.27 babel-jest: ^26.6.3 => 26.6.3 color: 3.1.3 => 3.1.3 eslint: 7.14.0 => 7.14.0 expo-image-picker: ^10.0.0 => 10.1.4 expo-localization: ^10.0.0 => 10.1.0 expo-location: ^11.0.0 => 11.0.0 expo-payments-stripe: ^9.0.0 => 9.2.3 expo-splash-screen: ^0.9.0 => 0.9.0 formik: 2.2.4 => 2.2.4 hermes-inspector-msggen: 1.0.0 i18n-js: ^3.8.0 => 3.8.0 inquirer: 8.0.0 => 8.0.0 jest: ^26.6.3 => 26.6.3 libphonenumber-js: 1.9.16 => 1.9.16 libphonenumber-js-core: 1.0.0 libphonenumber-js-max: 1.0.0 libphonenumber-js-min: 1.0.0 libphonenumber-js-mobile: 1.0.0 lodash: ^4.17.21 => 4.17.21 metro-react-native-babel-preset: ^0.64.0 => 0.64.0 prettier: 2.2.1 => 2.2.1 react: 17.0.1 => 17.0.1 react-native: 0.64.0 => 0.64.0 react-native-animated-spinkit: ^1.5.2 => 1.5.2 react-native-calendars: 1.1255.0 => 1.1255.0 react-native-confirmation-code-field: ^7.0.1 => 7.0.1 react-native-device-info: ^8.0.8 => 8.1.2 react-native-geolocation-service: 5.2.0 => 5.2.0 react-native-gesture-handler: ^1.10.3 => 1.10.3 react-native-google-places-autocomplete: 2.2.0 => 2.2.0 react-native-maps: ^0.28.0 => 0.28.0 react-native-paper: ^4.7.2 => 4.8.0 react-native-reanimated: 2.0.1 => 2.0.1 react-native-safe-area-context: 3.2.0 => 3.2.0 react-native-screens: 3.1.0 => 3.1.0 react-native-status-bar-height: ^2.6.0 => 2.6.0 react-native-svg: 12.1.0 => 12.1.0 react-native-unimodules: ^0.12.0 => 0.12.0 react-native-vector-icons: ^8.1.0 => 8.1.0 react-test-renderer: 17.0.1 => 17.0.1 ts-jest: ^26.5.4 => 26.5.5 ts-node: ^9.1.1 => 9.1.1 typescript: 3.8.3 => 3.8.3 world-countries: 4.0.0 => 4.0.0 yup: 0.32.9 => 0.32.9 npmGlobalPackages: @aws-amplify/cli: 4.48.0 npm: 7.10.0 ```

Describe the bug

When trying to start DataStore with DataStore.query(...), I get [TypeError: Symbol.asyncIterator is not defined.]. It appears only when I try to enable hermes js engine, otherwise, it seems to work properly.

Expected behavior

I expect it to work

Reproduction steps

Enable hermes in iOS or Android, on a bare React native application and try to start DataStore.

Code Snippet

// Put your code below this line.
  const startDataStore = async () => {
    try {
      console.log(`DATASTORE - starting`)
      const user = await Auth.currentUserInfo()
      //await DataStore.start()
      await DataStore.query(UserData, u => u.owner('eq', user.username))
    } catch (err) {
      console.log(`DATASTORE - error`)
      console.log(err)
      console.log('-----------------')
    }
  }

Log output

``` // Put your logs below this line LOG DATASTORE - starting LOG DATASTORE - error LOG [TypeError: Symbol.asyncIterator is not defined.] LOG {} LOG ----------------- ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

manueliglesias commented 3 years ago

Hi @Darapsas

I did a quick search on hermes repo and found facebook/hermes#227

Can you try the suggestions in there? (mainly providing a polyfill)

Darapsas commented 3 years ago

Hello @manueliglesias, thank you again for showing my braindeadiness, saw that post, installed the package, but forgot to import it and of course, didn't take it too seriously, because of the age it had... Anyhow, if any of you get this error, just do this:

npm install @azure/core-asynciterator-polyfill

or

yarn add @azure/core-asynciterator-polyfill

and most importantly do not forget to import the package before any other imports in your index.js file:

import '@azure/core-asynciterator-polyfill'

Clean rebuild your project and you should be good to go.

Kudos to the original answer writer @mhorowitz

moob123 commented 2 years ago

I have the same issue, I just noticed it is on the anniversary of this ticket :)

chrisbonifacio commented 2 years ago

@moob123 did the polyfill still work for you a year later?

moob123 commented 2 years ago

Yes, happy :) the info was much appreciated. Although somewhat amused, how is this not some basic issue for others, so that it is still not solved?

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server amplify-help forum.