-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[0.57.0] metroRequire errors: Require cycles are allowed, but can result in uninitialized values... #20841
Comments
YellowBox.ignoreWarnings(['Require cycle:']); |
@qinkaiabc I'm well aware of that cosmetic workaround. |
@qinkaiabc can you share your |
Hello, i also met this warning. |
@qinkaiabc Did you try this ?? |
That's only a warning - you need just to watch out to be sure you are not doing anything wrong there. But that's a yellow flag - if you have a A -> B -> A cycle, maybe worth extracting the shared code from A and B to C where both could make use of that. |
@daviscabral Hi. Is there any workaround found to suppress this warning? |
@ahmedakmal525 #20841 (comment) |
@fungilation I have 2 require cycle warnings similar to yours, that are caused by sentry-react-native (There is an issue open on their side here: getsentry/sentry-react-native#479). |
What is cycle?
|
It seems to me that these warnings are triggered by Metro "understanding" how files depends on each other, and that now all the cycles triggered by files inside the main There is no reason to keep this issue open, please submit PRs to the libraries that generate those errors and help them reduce these warnings :) It's Hacktoberfest and I think that this kind of PR would be much appreciated! Again, it's not a blocker nor a real issue, it's just a warning - and @shinriyo the basic explanation of the cycle concept in this scenario is *---> File A wants something from file B -> file B wants something from file C -> file C wants something from file A ---* There is a "circle" being created, and thus the warning says this may lead to uninitialized values. |
Umm, what's the fix? Without knowing, hard to tell/implement PRs for libraries (outside RN) that generate those errors. |
Not sure I follow, the warning details the cycle path, so it's easy to understand which files are causing Metro to detect a circle. Example: |
I think this warning should be muted for node_modules unless the user opts-in. In most cases people can't do anything about the warnings and so it just adds irritating noise. |
I made an issue on metro about this: facebook/metro#287 |
Environment
Description
Require cycle: node_modules\react-native\Libraries\Network\fetch.js -> node_modules\react-native\Libraries\vendor\core\whatwg-fetch.js -> node_modules\react-native\Libraries\Network\fetch.js
Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
With the packages my app uses, I count more than 10 similar errors from various packages.
Reproducible Demo
Should be reproducible in any app. I'm testing mine on Android, on Windows. For the expanded error in screenshot above, it's on RN's fetch().
My package.json
The text was updated successfully, but these errors were encountered: