JSON.parse: unexpected character at line 1 column 1 of the JSON data

Hi LT,

i got curious and installed LT on my server.

the problem i have run into is that when i try to translate more than one newspaper paragraph worth of text, i get this error message:

“JSON.parse: unexpected character at line 1 column 1 of the JSON data”

while processing the text, my servers two cores more or less max out, but memory is at about 50%. even after the error, my cores keep going at ~90% until i stop libretranslate on the command line. running “–debug” doesn’t show up anything when the error appears.

is this just a fact of lacking system resources or is there any further way i could find a way beyond this?


looks like this error is actually caused by nginx timeouts, which need to be set separately to libretranslate frontend timeouts:

eg by adding

   proxy_read_timeout 300;
   proxy_connect_timeout 300;
   proxy_send_timeout 300;

in the server or location block in the libretranslate config for nginx. perhaps something for docs, if bums like me with small setups are going to be tempted to use your software. :slight_smile:

but perhaps there is a way to also have a better handling of these errors? show the nginx info, but also, somehow, stop libretranslate continuing to use ~90% cpu after nginx has timed out.

to increase timeouts when running via gunicorn, add the -t flag followed by number of seconds: -t 300.

Hey @mooseyboots :raised_hand: thanks for sharing the solution! This would indeed be something useful to others. A note in the README or an example nginx configuration would be a wonderful addition (interested in making a pull request?)

i wouldn’t mind doing so, but i’m not sure that what works for me works for other LT installs more generally, as i don’t know nginx/wsgi config very well…

i thought best to start sharing and gathering info first.