Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

window.XMLHttpRequest Blocking firebase calls #634

Closed
amos80m opened this issue Jan 11, 2018 · 6 comments
Closed

window.XMLHttpRequest Blocking firebase calls #634

amos80m opened this issue Jan 11, 2018 · 6 comments

Comments

@amos80m
Copy link

amos80m commented Jan 11, 2018

Hi I am using:
"react": "16.0.0", "react-native": "0.51.0", "react-native-fetch-blob": "^0.10.8",
when i am using "window.XMLHttpRequest" i can upload my image to firebase bat canot write to firebas no more, whan i remove this i can write bat not upload the image.
my code is heare https://stackoverflow.com/questions/48215067/react-native-fetch-blob-is-blocking-firebase-calls-n-react-native-app
i dont know how to clear the window.XMLHttpRequest declaration on react native or reset it so the app can reach other calls.
please help

@rainbarrel
Copy link

rainbarrel commented Jan 28, 2018

I am having the exact same problem as described above when using this package within React Native. The required code window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest; allows me to successfully upload to Firebase Storage, but any subsequent calls, in my case, to Firebase Cloud Firestore (database) are blocked completely. When I comment out this line of code, uploading to Cloud Firestore database DOES work, but Firebase Storage no longer does. Do you have any recommendations, solutions with this? Like Amos says, to maybe reset the window back to default windowafter my Firebase Storage upload? Thank you.

NOTE: upon further testing: this error only arises for me in the Cloud Firestore database (beta), it does not arise in the Firebase Realtime Database. It is working there.

@amos80m
Copy link
Author

amos80m commented Feb 18, 2018

I am uploading to my node js app and from there connecting to firebase for uploading and saving the images in any size/blob....working 100%

@amos80m amos80m closed this as completed Feb 18, 2018
@terranball
Copy link

I'm having the exact same problem-- did anyone figure out how to resolve this?

@rainbarrel
Copy link

@terranball if this helps at all, what I did was the following (again, my issue was making a call specifically from my React Native app to Firebase Cloud Firestore):

As you see, it's a little hacky, but is currently working well for me. I set the window.XMLHttpRequest to a temp variable, then do my thing with react-native-fetch-blob, then later on, right before I am about to make my call to Cloud Firestore, I reset window.XMLHttpRequest to the original temp variable.

const Blob = RNFetchBlob.polyfill.Blob;
window.Blob = Blob;
const tempWindowXMLHttpRequest = window.XMLHttpRequest;
window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest;
...
window.XMLHttpRequest = tempWindowXMLHttpRequest;

@mikelehen
Copy link

Could this be re-opened? It is causing problems with Firebase's SDK for Google Cloud Firestore as well. It would be really nice if the polyfill could be fixed to be fully compatible or else better scope its usage so that it doesn't affect other libraries.

@chenchuen
Copy link

Hi, I'm new to react-native. Im also getting the same issue when I wanna upload an image to firebase. Can I know where is the "window" variable is declared? and what is it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants