rn-fetch-blob icon indicating copy to clipboard operation
rn-fetch-blob copied to clipboard

Require cycle

Open mengerzhuanyong opened this issue 6 years ago • 81 comments

Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/FileReader.js -> node_modules/rn-fetch-blob/index.js

It is recommended to solve this problem!

mengerzhuanyong avatar Sep 14 '18 06:09 mengerzhuanyong

I'm also getting these warnings on the new version of react-native.

Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/Blob.js -> node_modules/rn-fetch-blob/index.js
Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/XMLHttpRequest.js -> node_modules/rn-fetch-blob/index.js
Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/FileReader.js -> node_modules/rn-fetch-blob/index.js
Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/Fetch.js -> node_modules/rn-fetch-blob/index.js

reilem avatar Sep 17 '18 09:09 reilem

Same issue

joegoodall2 avatar Sep 25 '18 11:09 joegoodall2

same issue

zhaiyjgithub avatar Sep 29 '18 02:09 zhaiyjgithub

same issue

mitevdev avatar Oct 05 '18 08:10 mitevdev

Yes, I've faced the same issue here.

tenwiz avatar Oct 14 '18 14:10 tenwiz

Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/Blob.js -> node_modules/rn-fetch-blob/index.js

tenwiz avatar Oct 14 '18 14:10 tenwiz

Same issue :(

tskorupka avatar Oct 15 '18 13:10 tskorupka

same here

burtek avatar Oct 24 '18 16:10 burtek

same here, any idea?

rodrigowpl avatar Oct 26 '18 20:10 rodrigowpl

I've got the same.

sithartha avatar Oct 30 '18 15:10 sithartha

Same Here

tylerbarnett avatar Oct 31 '18 02:10 tylerbarnett

Any one already working on this issue? Or any one has an idea to solve this?

AsadSaleh avatar Nov 24 '18 09:11 AsadSaleh

@AsadSaleh This is not a critical problem, just a warning for 'maybe there is something wrong in your code', so you can simply ignore this warning by add codes like bellow, and wait someone will fix this warning ...

YellowBox.ignoreWarnings([
    'Remote debugger is in a background tab which may cause apps to perform slowly',
    'Require cycle: node_modules/rn-fetch-blob/index.js',
    'Require cycle: node_modules/react-native/Libraries/Network/fetch.js'
]);

wd avatar Nov 26 '18 09:11 wd

any update on this ?

qiaolin-pan avatar Dec 05 '18 02:12 qiaolin-pan

@wd This is a warning but needs to be dealt with. This has come up with new react-native version (0.57) and requires certain code restructuring in rn-fetch-blob library.

Is anyone working on this?

soumyamishra89 avatar Dec 06 '18 09:12 soumyamishra89

I also encountered this problem today.

AGOGD avatar Dec 13 '18 08:12 AGOGD

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

// import RNFetchBlob from '../index.js' import {NativeModules} from 'react-native'; const RNFetchBlob = NativeModules.RNFetchBlob

zhuxianqin avatar Jan 02 '19 10:01 zhuxianqin

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

// import RNFetchBlob from '../index.js' import {NativeModules} from 'react-native'; const RNFetchBlob = NativeModules.RNFetchBlob

this problem has resolved, thanks brother

nhuthuynh195 avatar Jan 02 '19 15:01 nhuthuynh195

there is going to be a PR for @zhuxianqin fix ???

Zbish avatar Jan 16 '19 12:01 Zbish

@zhuxianqin can you please submit a PR with this fix?

Faolain avatar Jan 19 '19 21:01 Faolain

@zhuxianqin can you please submit a PR with this fix?

sorry, I don't know how to release github project, I will try to do it in several days

zhuxianqin avatar Jan 31 '19 04:01 zhuxianqin

@zhuxianqin can you please submit a PR with this fix?

to develop this project, I need to follow instructions below: https://github.com/joltup/rn-fetch-blob-dev I have to test both on android & IOS Sorry, I think it's better for the original owner to fix it

zhuxianqin avatar Feb 09 '19 09:02 zhuxianqin

@zhuxianqin seems that they are not adding it, it sucks man :(

Seems that you know this library a lot, though. Can you help me with something? I created this post https://github.com/joltup/rn-fetch-blob/issues/305

msqar avatar Feb 10 '19 00:02 msqar

This should be fixed. I'm glad react-native now warns about this but there should have never been cyclic dependencies in the first place.

here it is solved with constructor injection: https://stackoverflow.com/questions/38841469/how-to-fix-this-es6-module-circular-dependency/44226565#44226565

https://github.com/react-native-community/react-native-svg/issues/773

Another way to solve this is to make an interface with a setter and a getter and require the interface instead of the original class. The original file uses the setter and all others use the getter.

interface.js:

let thing = {}

export function getThing () {
  return thing
}

export function setThing (thingToSet) {
  thing = thingToSet
}

thing.js:

import {setThing} from './interface'

class Thing {}

setThing(Thing)

other files:

import {getThing} from './interface'

const Thing = getThing()

ThaJay avatar Feb 20 '19 17:02 ThaJay

@ThaJay yea man, i receive like 6-7 warning notifications every time i refresh the app, is getting super annoying. Do you have any idea how to apply this interface for this specific case?

msqar avatar Feb 20 '19 17:02 msqar

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

// import RNFetchBlob from '../index.js' import {NativeModules} from 'react-native'; const RNFetchBlob = NativeModules.RNFetchBlob

This did the trick on RN 0.57 This bug should be fixed...

vitorverasm avatar Feb 20 '19 21:02 vitorverasm

@vitor-veras i have to put the fetch-blob file in my app and edit it then? no other way until they fix this? :/ i don't get it, i assume i don't have to update these files directly from node_modules otherwise it will be over-written whenever i do another npm install... so how should i do it?

msqar avatar Feb 21 '19 00:02 msqar

That's only a warning from React Native, but it can slowdown the app performance. And yes if you update the package with npm/yarn the fix will go away. There's no proper aproach to this i think, hopefully the dev team fix this soon. There is actually a PR for this #296 .

vitorverasm avatar Feb 21 '19 02:02 vitorverasm

As mentioned by @alpha0010 in #296 one would encounter problems where RNFetchBlob is called within the files the import is removed from.

@ThaJay would you be able to submit a PR?

Faolain avatar Mar 09 '19 22:03 Faolain

Just stupid me, but why are these polyfills even required here? As RN 0.59 comes with a new JavaScriptCore, are these polyfills still necessary? Or is there even a way to DISABLE these polyfills, like a non-polyfilled version of the lib?

FibreFoX avatar Mar 10 '19 14:03 FibreFoX