Skip to content
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

Bug Report - App gets Crash while searching the location !!! #944

Open
Hassaan0 opened this issue Aug 12, 2024 · 4 comments
Open

Bug Report - App gets Crash while searching the location !!! #944

Hassaan0 opened this issue Aug 12, 2024 · 4 comments
Labels

Comments

@Hassaan0
Copy link

Description

When users perform multiple rapid taps on the search bar in the app, it causes the app to crash. The issue occurs specifically when searching for locations, such as "IV George Avenue, Paris, France," and is triggered by aggressive interaction with the search function. This issue results in errors related to the GooglePlaceAutocomplete.js file. Specifically, it returns the error "Request has not been opened" and occasionally throws a "Cannot read property 'length' of undefined" error.

Reproduction

  • Open the app.
  • Navigate to the search bar.
  • Tap on the search bar repeatedly and rapidly (multiple times in quick succession).
  • Enter a location such as "IV George Avenue, Paris, France" and initiate the search.
  • Observe that the app crashes after several rapid taps.
  • Observe that the app crashes, and check the error messages:
    • Request has not been opened" at GooglePlaceAutocomplete.js (line: 339, 501, 570)
    • Cannot read property 'length' of undefined" (error may vary)

**Example of Code. **

Click to expand!
  <GooglePlacesAutocomplete
ref={ref}
disableScroll
query={{
  key: "MY_API_KEY",
  language: "en",
}}
minLength={2} 
listViewDisplayed="auto"
fetchDetails={true}
enableHighAccuracyLocation
onPress={async (data, details = null) => {
  const loc = details?.geometry?.location;
  if (!loc) {
    return;
  }
  console.log(details);
}}
styles={{
  textInputContainer: {
    flexDirection: "row",
    borderWidth: 1,
    borderRadius: 16,
    marginBottom: 5,
  },
  textInput: {
    borderRadius: 16,
    fontSize: 16,
  },
  row: {
    gap: 16,
    height: 45,
    marginVertical: 1,
    borderRadius: 16,
    paddingHorizontal: 10,
  },
}}
textInputProps={{
  onBlur: (e) => {
    e.preventDefault();
    e.stopPropagation();
  },
  onPressIn: () => {
    setState({
      item_selected: false,
    });
  },
}}
keepResultsAfterBlur
nearbyPlacesAPI="GooglePlacesSearch"
GooglePlacesDetailsQuery={{
  fields: "formatted_address,geometry",
}}
keyboardShouldPersistTaps="handled" 
debounce={300}// debounce the requests in ms. Set to 0 to remove debounce. By default 0ms.
/>

Additional context

  • Library Version: ^2.5.6

  • React Native Version: 0.73.6

  • [Yes] iOS

  • [Yes] Android

** ERROR SCREENSHOT **

simulator_screenshot_907BFB7A-ACF3-4897-8320-B28D5A392B4E

@Hassaan0 Hassaan0 added the bug label Aug 12, 2024
@cameronmurphy
Copy link

+1

1 similar comment
@rousseau634
Copy link

+1

@naveedashfaq272
Copy link

+1 also facing the same issue...
@Hassaan0 did you find any solution for it ??

@Hassaan0
Copy link
Author

+1 also facing the same issue... @Hassaan0 did you find any solution for it ??

I implemented a temporary workaround to prevent the app from crashing, though I acknowledge it's not an ideal or permanent solution.

To do this, navigate to the file: node_modules/react-native-google-places-autocomplete/GooglePlacesAutocomplete.js. Locate the request.send() function and enclose it within a try-catch block.

Please note that if you ever delete the node_modules directory, you'll need to repeat this step, which can be quite inconvenient.

ga-hoog pushed a commit to gabrielhoog/react-native-google-places-autocomplete that referenced this issue Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants