google-translate-api
google-translate-api copied to clipboard
Caught an error from batch translate
Hi @AidanWelch
I caught a new error from the below codes.
trInput is an array for batch translation.
It doesn't happen all the time, maybe 1 out of 4 or 5 times. Even when all the variable values are exactly the same for all the 4 or 5 times.
const translation = await translate(trInput, {from: userLanguage, to: addHelperLanguage && helperLanguage, autoCorrect: true})
.catch((error) => {
console.error('translate| translate-google-api-x error: ', error.message)
throw error
});
Error caught in below
translate| translate-google-api-x error: Cannot read properties of null (reading '1')
Url: https://translate.google.com/_/TranslateWebserverUi/data/batchexecute?rpcids=MkEWBc&source-path=%2F&f.sid=3998618730767360818&bl=boq_translate-webserver_20230409.08_p0&hl=en-US&soc-app=1&soc-platform=1&soc-device=1&_reqid=7749&rt=c
The value returned from the Url in the error in below
)]}'
103
[["er",null,null,null,null,405,null,null,null,9],["di",17],["af.httprm",17,"-2930294764364961249",6]]
25
[["e",4,null,null,139]]
I'm able to replicate a similar error by spamming thousands of requests in quick succession responding with:
)]}'
105
[["er",null,null,null,null,400,null,null,null,3],["di",17],["af.httprm",17,"-8356414571367733663",103]]
25
[["e",4,null,null,141]]
I would say just try varying requests, as one of the test unit tests is 1000 requests and it doesn't have any issues. Also don't send 1000+ at the exact same time. You can also try using a proxy.
Thanks @AidanWelch
I only sent 2 identical sentences in the array, to translate to different languages. I guess I will need a retry bloc.
Huh, that is weird maybe Google is changing their rate limits. You can also try calling with forceBatch: false
if you're just trying individual strings. So that it at least spreads out your requests across endpoints.
I get a similar issue with an empty string.
I get a similar issue with an empty string.
Interesting, that doesn't seem breaking though
Yes, it is not breaking but it can be hard to figure the reason. So, I have raised a PR which can help in such a situation for this situation. It can be helpful when the user unknowingly inputs empty strings.
Can you see if updating to v10.6.5 helps with the error logging of your issue?
The error logging works, but it seems like batch requests are failing too often, it may be to do with the init. Will investigate