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

Unhandled Promise Rejection. Error.captureStackTrace #121

Open
Kefir101 opened this issue Jun 23, 2023 · 11 comments
Open

Unhandled Promise Rejection. Error.captureStackTrace #121

Kefir101 opened this issue Jun 23, 2023 · 11 comments

Comments

@Kefir101
Copy link

I had to come back to this specific API because now I need the language found as well. Removing the api call makes the code works fine, so it has to be here.

Running for react-native and expo app on windows, all I'm doing is a simple call using the documentation (in an async function). React native 69.9, expo sdk 46, react 18. Not sure what else to put.
image

@vitalets
Copy link
Owner

Could you share minimal reproducible code of your app?

@Kefir101
Copy link
Author

I'll try that, but it will take a while to get the minimal amount. At least a few days.

@Kefir101
Copy link
Author

Kefir101 commented Jul 2, 2023

I'm still working on it, but what I noticed is after starting the expo server after a while again the translate worked twice and then it gives the stacktrace error every time after, so I think it has something to do with caching in your code.

@Kefir101
Copy link
Author

Kefir101 commented Jul 2, 2023

@vitalets
Copy link
Owner

vitalets commented Jul 2, 2023

@Kefir101 Is this error appears on app launch or after making actual call to translate()?
And could you try to check and log text value before translation (I assume empty text can trigger an error)?

async function parseTextBothWays(text) {
  if (text) {
    console.log(text);
    let translated = await translate(text, { to: 'en' });
  }
}

And just as experiment, could you replace translate() call with explicitly triggered error and share the results, like:

async function parseTextBothWays(text) {
  if (text) {
    console.log(text);
    // let translated = await translate(text, { to: 'en' });
   throw new Error('my error');
  }
}

@Kefir101
Copy link
Author

Kefir101 commented Jul 2, 2023

@vitalets Error only appears when making the translate() call, but I noticed it now took 5-10 pictures to start giving the error, I think it has something to do with how much text has been translated already. Translating "" (empty) still gives the error, and replacing the translate() with throwing 'my error' leads to only seeing [Unhandled promise rejection: Error: my error].

@Kefir101
Copy link
Author

Kefir101 commented Jul 7, 2023

@vitalets What do you think I should test out next?

@vitalets
Copy link
Owner

vitalets commented Jul 9, 2023

I've tried to reproduce it on https://github.com/Kefir101/Shortened-VeganChecker but was not able to run it.
When running npm start and scanning qr code (ios) I'm getting error that there is no valid data. The output is following:

› Metro waiting on exp+veganchecker://expo-development-client/?url=http%3A%2F%2F192.168.10.13%3A8081
› Scan the QR code above with Expo Go (Android) or the Camera app (iOS)

I suppose this is because of exp+veganchecker:// scheme but I don't know how to fix it.

Lets do the following:

  1. could you log all texts that used for translation in 5-10 times before error occurs
  2. create fresh React Native app, include only @viatelst/google-translate-api and run translation in a loop of all these texts (with some delay to replicate how it occurs in VeganChecker)
  3. If error still occurs, paste these texts here and I will try to replicate myself. If there will be no error - we will continue search in VeganChecker

@Kefir101
Copy link
Author

Kefir101 commented Jul 9, 2023

@vitalets I was doing npx expo start instead, that might be why it didn't work for you.

@vitalets
Copy link
Owner

@vitalets I was doing npx expo start instead, that might be why it didn't work for you.

Yes, that helped! Now I'm getting error:

iOS Bundling failed 9ms
Unable to resolve "./config.js" from "helperFunctions.js"

I see that config.js is in gitignore as it seems it contains some sensitive data. Is there way to run app somehow?

@Kefir101
Copy link
Author

Kefir101 commented Jul 23, 2023

Ah right, I’m using Google Vision which requires an API key so I hid it in the config file. But getting rid of that makes it hard to test, so I’m not sure how to proceed. I have gone on vacation so I will get back to this later, thank you so much for your help so far.

@Kefir101 Kefir101 reopened this Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants