Require cycle fetch
See original GitHub issueEnvironment
How do you use Sentry? Sentry SaaS (sentry.io)
Which SDK and version?
"@sentry/react-native": "^3.2.13",
"@sentry/node": "^6.17.8",
"@sentry/tracing": "^6.17.8",
Steps to Reproduce
- Install sentry and setup according to docs
- Run app
Expected Result
No require cycle upon running the app
Actual Result
Getting a require cycle warning from sentry-react-native
:
Require cycle: node_modules\react-native\Libraries\Network\fetch.js -> node_modules\whatwg-fetch\dist\fetch.umd.js -> node_modules\react-native\Libraries\Network\fetch.js
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (16 by maintainers)
Top Results From Across the Web
Warning 'Require cycle' between fetch.js & whatwg ... - GitHub
Description. Working with react-native@0.57.7 , I encounter this warning: Require cycle: node_modules\react-native\ ...
Read more >Trying to use fetch results in "Require cycle..." : r/reactnative
I'm not doing anything special, i'm simply trying to use fetch to perform a network request, but that results in a HUGE warning...
Read more >Require cycles are allowed, but can result in uninitialized ...
js This is what triggers the Require cycle warning because a module that was imported from one place, is then rendering and asking...
Read more >Trying to use fetch results in "Require cycle..." | JavaScript LibHunt
Doing some googling I arrive at this issue: github.com/facebook/react-native/issues/23130 which is closed and locked and points to this issue ...
Read more >require cycle node_modules/rn-fetch-blob/index.js
Modify these files can avoid require cycle: // IN DIR rn-fetch-blob/polyfill // all thease 4 files: Blob.js, Fetch.js, FileReader.js, XMLHttpRequest.js ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We currently don’t have the cycles to investigate as we are focusing on the major JS SDK bump.
The major version does change how transports work, so let’s re-visit this after that!
Ok after further investigation here are the lines that triggers the require cycle. when the browser backend calls
supportsFetch()
.I assume it’s something with how React Native lazy-initializes some functionality and fetch seems to be one of them. The line calling
new Headers()
triggers the polyfill fromwhatwg-fetch
to be run, which leads to the require cycle. The warning does not show if you trigger the lazy initialized fetch beforehand by adding a fetch call beforeAlso, calling
new Headers()
or any of the others later in the lifecycle of the app poses no issue. Which means for some reason our SDK is getting initialized very early on before the fetch polyfill I assume is eventually called by default?