google-translate-api
google-translate-api copied to clipboard
Unhandled Promise Rejection. Error.captureStackTrace
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.
Could you share minimal reproducible code of your app?
I'll try that, but it will take a while to get the minimal amount. At least a few days.
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.
@vitalets https://github.com/Kefir101/Shortened-VeganChecker
@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');
}
}
@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].
@vitalets What do you think I should test out next?
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:
- could you log all texts that used for translation in 5-10 times before error occurs
- 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) - 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
@vitalets I was doing npx expo start
instead, that might be why it didn't work for you.
@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?
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.