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

Require Cycle and Async Storage warning #6031

Closed
ThatMate opened this issue Jun 7, 2020 · 44 comments
Closed

Require Cycle and Async Storage warning #6031

ThatMate opened this issue Jun 7, 2020 · 44 comments
Assignees
Labels
React Native React Native related issue

Comments

@ThatMate
Copy link

ThatMate commented Jun 7, 2020

I am using aws-amplify@3.0.16 which is the latest at this point. I am using it for my React Native project. I am seeing two warnings:

[Sun Jun 07 2020 15:28:29.187]  WARN     Require cycle: node_modules/@aws-amplify/pubsub/lib-esm/index.js -> node_modules/@aws-amplify/pubsub/lib-esm/PubSub.js -> node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js -> node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js -> node_modules/@aws-amplify/pubsub/lib-esm/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
[Sun Jun 07 2020 15:28:29.190]  WARN     Require cycle: node_modules/@aws-amplify/datastore/lib-esm/util.js -> node_modules/@aws-amplify/datastore/lib-esm/types.js -> node_modules/@aws-amplify/datastore/lib-esm/util.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.

AND

Warning: Async Storage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '@react-native-community/async-storage' instead of 'react-native'. See https://github.com/react-native-community/react-native-async-storage

I see a PR (#5372) merged a few days ago, but it does not seem to fix the issue.

@ThatMate ThatMate added the to-be-reproduced Used in order for Amplify to reproduce said issue label Jun 7, 2020
@Ashish-Nanda Ashish-Nanda added the React Native React Native related issue label Jun 8, 2020
@Ashish-Nanda
Copy link
Contributor

@ThatMate investigating the require cycles.

Regarding AsyncStorage migration to the community package we are working on the change. Will have a PR for that in the near future.

@AlexandruCalinica
Copy link

I'm having the same issues with aws-amplify@3.0.17 and aws-amplify-react-native@4.2.0. Fresh install of a react native project. Are these warnings going to affect my project in the longterm?

@Ashish-Nanda Ashish-Nanda self-assigned this Jun 18, 2020
@Davidson-Mike
Copy link

Hello, I'm having the same issue as well with aws-amplify@3.0.18
The async storage warning I'm not too concerned about but the require cycles should be resolved right away.

@ThatMate
Copy link
Author

Any updates?

@ankur-1989
Copy link

same issue +1

@sammartinez sammartinez added AsyncStorage and removed to-be-reproduced Used in order for Amplify to reproduce said issue labels Sep 16, 2020
@arodri48
Copy link

I have been running into the same issue. I hope a fix for this is generated soon. Please keep us updated.

@kilisoria
Copy link

Hi Guys! same issue here. Anyone has some news? Thanks!

@Sacinandan
Copy link

Sacinandan commented Sep 25, 2020

Hello! Same issue.

I replaced the import for AsyncStorage in node_modules, but still has an issue with Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle:

WARN     Require cycle: node_modules/@aws-amplify/pubsub/lib-esm/index.js -> node_modules/@aws-amplify/pubsub/lib-esm/PubSub.js -> node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js -> node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js -> node_modules/@aws-amplify/pubsub/lib-esm/index.js

WARN     Require cycle: node_modules/@aws-amplify/datastore/lib-esm/util.js -> node_modules/@aws-amplify/datastore/lib-esm/types.js -> node_modules/@aws-amplify/datastore/lib-esm/util.js

WARN     Require cycle: node_modules/aws-amplify/lib-esm/index.js -> node_modules/aws-amplify/lib-esm/withSSRContext.js -> node_modules/aws-amplify/lib-esm/index.js

@keisan1231
Copy link

same issue😓

@ghost
Copy link

ghost commented Sep 25, 2020

Same issue here

@Naes0
Copy link

Naes0 commented Sep 29, 2020

same issue

@itsmelion
Copy link

Well, these are two different problems, so keep a better track of progress and conversations i think should be 2 issues.

In my case,

  • i still get is deprecation warning of AsyncStorage from react-native core.
  • I don't get the require cycle after i changed from using the main repo default exports (aka: Amplify from 'aws-amplify') to granularly the ones i needed ex:
import Auth from '@aws-amplify/auth';
import Amplify from '@aws-amplify/core';

obviously i stopped getting it, because it seems the cycles are in PubSub/Datastore/others..
so if you are not using these services, i recommend you to do this.

@ajnunez16
Copy link

same issue

@seyedasfar
Copy link

any fix?

@Junhano
Copy link

Junhano commented Oct 24, 2020

any update?

@giulio-dds
Copy link

Unfortunately I also have the same issue on my app (React Native w. Amplify). I don't know if it happens to the others as well, but after that, the application runs various instances of BUNDLE ./index.js until the app crashes (actually it's freezing my screen).
After a rafresh everything is ok, anyway... is not so comfortable because it happens very often.

@seyedasfar
Copy link

I just go through the source code the issue is AsyncStorage had been imported from react-native but AsyncStorage had moved to a sperate dependency which managed by the react-native community @react-native-community/async-storage I don't get time to fix this and PR it.

@stale
Copy link

stale bot commented Nov 29, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@itsmelion
Copy link

No bot, the require cycles still need need to be dealt with.

@serhiiharbo
Copy link

Long story short:
I've dealt with Async Storage warning by patching the @aws-amplify source.

Long story long 🙄:
After I've read this comment and reviewed this PR#4402 and because we don't use Expo I decided to not wait until amazon guys will push the fix.
Here is how I deal with
Warning: Async Storage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '@react-native-community/async-storage' instead of 'react-native'. See https://github.com/react-native-community/react-native-async-storage warning:

We use patch-package in our RN project.
Here is the usage explanation. Which is can be shortened to:
Let's say we're using aws-amplify in our app. And you want to replace -import { AsyncStorage } from 'react-native'; with +import AsyncStorage from '@react-native-community/async-storage';.

  1. Open file "package.json" and remove line
    "postinstall": "patch-package && ./scripts/whatever.sh"
    from "scripts:" section and save the changes
  2. Execute
    yarn clean
    from root folder of the project
  3. Make the desired changes to the source files and save them
  4. Execute
    yarn patch-package @aws-amplify/core && yarn patch-package @aws-amplify/cache && yarn patch-package @aws-amplify/datastore
    from root folder of the project, it compares a clean install to your modified dependency
  5. Check new .patch file in patches directory and build the project to check does it help.
  6. Revert changes from step 1 and commit your code.
  7. Voila, you don't see ugly warning any more 😊

Step 3 in details:

  • go node_modules/@aws_amplify
  • find all lines with import { AsyncStorage } from 'react-native' in *.js & *.ts files
  • replace it with import AsyncStorage from '@react-native-community/async-storage'
  • 👌 perfecto!

Disclamer:
Also, I tried to add line "@react-native-community/async-storage": "^1.6.2", to the "dependencies" and "devDependencies" sections on node_modules/@aws-amplify/core/package.json, but I didn't see that in .patch file nor in package.json after applying the patch (which is expectable 🙈).
However, I believe you already has @react-native-community/async-storage in your package.json, so it should work.

@stale
Copy link

stale bot commented Jan 10, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@yev-yev-yev
Copy link

+1 same issue

@ws333
Copy link

ws333 commented Apr 15, 2021

+1

@bmoby
Copy link

bmoby commented Apr 20, 2021

+1 same

2 similar comments
@dsmlucas
Copy link

+1 same

@gvankeerberghen
Copy link

+1 same

@jonnyn
Copy link

jonnyn commented May 5, 2021

+1 same issue

@sammartinez
Copy link
Contributor

All,

I wanted to provide an update here. We are going to be migrating to the Community version of Async Storage in the coming weeks. This will be a breaking change and a major version bump for us, so we are working on the logistics of this prior to getting it out to you folks. Just wanted to state, we hear you and will provide more of an update once we have something.

Thanks!
Sam

@sotomaque
Copy link

Thanks for the update!

@Ashish-Nanda
Copy link
Contributor

Ashish-Nanda commented May 10, 2021

Hi All,
The PR #8250 to migrate to the community version of AsyncStorage has just been merged to main
You can now test the changes on the @unstable tag.

// React Native
yarn add aws-amplify@unstable amazon-cognito-identity-js @react-native-community/netinfo @react-native-async-storage/async-storage
npx pod-install

// Expo
yarn add aws-amplify@unstable @react-native-community/netinfo @react-native-async-storage/async-storage

We plan to release the this change in our next major version tomorrow.

@Ashish-Nanda
Copy link
Contributor

Hi All,
We released aws-amplify@4.0.0 that uses the community version of AsyncStorage @react-native-async-storage/async-storage

Please take a look at the installation and setup instructions here

Closing out this issue now since the fix has been released.

@plus-
Copy link

plus- commented Jun 9, 2021

I believe this does not fix the require cycles issue posted initially (there were 2 issues reported together originally)

I've tested with 4.0.3 and still get the following:

WARN Require cycle: ../../node_modules/@aws-amplify/pubsub/lib-esm/index.js -> ../../node_modules/@aws-amplify/pubsub/lib-esm/PubSub.js -> ../../node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js -> ../../node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js -> ../../node_modules/@aws-amplify/pubsub/lib-esm/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
WARN Require cycle: ../../node_modules/@aws-amplify/datastore/lib-esm/types.js -> ../../node_modules/@aws-amplify/datastore/lib-esm/util.js -> ../../node_modules/@aws-amplify/datastore/lib-esm/types.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
WARN Require cycle: ../../node_modules/aws-amplify/lib-esm/index.js -> ../../node_modules/aws-amplify/lib-esm/withSSRContext.js -> ../../node_modules/aws-amplify/lib-esm/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.

@cyim02
Copy link

cyim02 commented Jun 9, 2021

+1 Same here.... Require Cycle issue has not been fixed! Please reopen the issue.

I believe this does not fix the require cycles issue posted initially (there were 2 issues reported together originally)

I've tested with 4.0.3 and still get the following:

WARN Require cycle: ../../node_modules/@aws-amplify/pubsub/lib-esm/index.js -> ../../node_modules/@aws-amplify/pubsub/lib-esm/PubSub.js -> ../../node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js -> ../../node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js -> ../../node_modules/@aws-amplify/pubsub/lib-esm/index.js
Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
WARN Require cycle: ../../node_modules/@aws-amplify/datastore/lib-esm/types.js -> ../../node_modules/@aws-amplify/datastore/lib-esm/util.js -> ../../node_modules/@aws-amplify/datastore/lib-esm/types.js
Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
WARN Require cycle: ../../node_modules/aws-amplify/lib-esm/index.js -> ../../node_modules/aws-amplify/lib-esm/withSSRContext.js -> ../../node_modules/aws-amplify/lib-esm/index.js
Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.

@sammartinez
Copy link
Contributor

@plus- and @thomasyim02 I created an issue for what you are calling out for Require Cycles. Can you please place any examples (similar to your code snippets above) in the new issue? Thanks ahead of time!

@themse
Copy link

themse commented Jun 15, 2021

react-native : 0.64.2
aws-amplify : 4.1.0
@react-native-async-storage/async-storage: 1.15.5

Require Cycles still exist

@sammartinez
Copy link
Contributor

Thanks for this feedback @themse I created a separate issue for this above. Can you please add your data to this issue?

@kartikeyvaish
Copy link

"react-native": "0.64.3",
"aws-amplify": "^4.3.18",
"@react-native-async-storage/async-storage": "^1.17.3",

Require Cycles still exist

@joseasanchezzz91
Copy link

same issue

"aws-amplify": "4.2.11",
"react": "17.0.2",
"react-native": "^0.66.5",
"@react-native-async-storage/async-storage": "^1.15.8",

Require Cycles still exist

@ParkAward
Copy link

same issue +1

"aws-amplify": "5.0.1",
"react": "17.0.2",
"react-native": "^0.65.3",
"@react-native-async-storage/async-storage": "^1.15.14",

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

No branches or pull requests