Closed Willham12 closed 1 month ago
"react-native": "0.72.5",
Same error here after upgrading the react native version.
I would highly appreciate any insights to this issue, thanks the awesome work.
Same issue
Same problem
any solution?
same problem here
i fixed it by removing the line that throw Error.
Go to react-native>Libraries>Network>XMLHttpRequest.js Line 517
- throw new Error('Request has not been opened'); + console.warn('Request has not been opened');
then patch-package react-native that's all
@FaridSafi : Any update? When this will be fixed inside the package?
Update on this? Experiencing the same issue, is the solution really to remove the error logic itself?
My solution I am not use lib, I use url from google
https://maps.googleapis.com/maps/api/place/autocomplete/json ?input=Vict &language=fr &types=geocode &key=YOUR_API_KEY
https://developers.google.com/maps/documentation/places/web-service/autocomplete
i fixed it by removing the line that throw Error.
Go to react-native>Libraries>Network>XMLHttpRequest.js Line 517
- throw new Error('Request has not been opened'); + console.warn('Request has not been opened');
then patch-package react-native that's all
I recommend instead modifying GooglePlacesAutocomplete.js, right before request.send()
on line 570 add an if-gate to catch any unopened requests before calling request.send(). The error is being caused by request.send() being called on a request that is not yet opened. You can check for this case and only send if the request is opened, or readyState === 1, with:
if (request.readyState === 1) {
request.send();
} else {
console.warn('google places autocomplete: attempt to send unopened request failed');
}
This way you at least don't have to alter the logic for all XMLHttpRequest(which I am personally uncomfortable with), just the offending GooglePlacesAutocomplete logic.
I did not spend time looking into why/how a single request is failing to set readyState = 1. Someone else may dig into that and solve the overall issue. On my end, only 1 request out of many was failing to set readyState = 1, causing the 'Request has not been opened' error. This only occurs after the user navigates away from the screen that contains the GooglePlacesAutocomplete component/import.
Go ahead and add a console log right before line 570 in GooglePlacesAutocomplete.js and see what you get, make sure to log out any request where request.readyState !== 1 so you catch requests that aren't open when they should be. If you're getting the error from a different line in GooglePlacesAutocomplete, I recommend doing the same console logging wherever the nearest request.send() is to your error, you may be able to find a solution to your problem.
Hope this helps, happy coding.
Setting debounce to more than 0 (eg. debounce={300}) fixed the issue for me.
Setting debounce to more than 0 (eg. debounce={300}) fixed the issue for me.
Can you explain where to set debounce please !
Setting debounce to more than 0 (eg. debounce={300}) fixed the issue for me.
Can you explain where to set debounce please !
You can put the prop in GooglePlacesAutocomplete
<GooglePlacesAutocomplete debounce={300} />
But it doesn't work, still throws an error.
wrapping [ request.send(); ] everywhere with try catch block solved my crash in release.
Setting debounce to more than 0 (eg. debounce={300}) fixed the issue for me.
Thank you, the issue has been resolved for me. However, I'm curious as to why this problem occurred. I've been using 'react-native-google-places-autocomplete' for the past 6-7 months without any issues, and now it suddenly appeared. Could you provide some insight into why this might have happened?
v2.5.3
See https://github.com/FaridSafi/react-native-google-places-autocomplete/blob/master/GooglePlacesAutocomplete.js#L559