Request may be translated to the wrong language due to race condition #2

Closed
opened 6 years ago by trinity-1686a · 2 comments
Owner

There is a race condition due to use of a global variable to store language, if two request are made close enought, one will inherit the language of the other
How to reproduce :

$ for i in `seq 1 50`; do curl https://baptiste.gelez.xyz/ -H "Accept-Language: en" 2>/dev/null  | grep 'h1'& done
$ for i in `seq 1 50`; do curl https://baptiste.gelez.xyz/ -H "Accept-Language: fr" 2>/dev/null  | grep 'h1'& done

Running one command then another give consistant results, but running both at the same time on different terminals sometime give inconsistant language result.
I don't know how this can be easily fixed as gettext-rs make heavy use of global state to store local

There is a race condition due to use of a global variable to store language, if two request are made close enought, one will inherit the language of the other How to reproduce : ```sh $ for i in `seq 1 50`; do curl https://baptiste.gelez.xyz/ -H "Accept-Language: en" 2>/dev/null | grep 'h1'& done $ for i in `seq 1 50`; do curl https://baptiste.gelez.xyz/ -H "Accept-Language: fr" 2>/dev/null | grep 'h1'& done ``` Running one command then another give consistant results, but running both at the same time on different terminals sometime give inconsistant language result. I don't know how this can be easily fixed as gettext-rs make heavy use of global state to store local
elegaanz commented 6 years ago (Migrated from github.com)

Yes, I think it is because Rocket is asynchronous as it uses threads. The only easy fix is to run the app with ROCKET_WORKERS=1, but that would result in lower performances and is not a possible solution.

Yes, I think it is because Rocket is asynchronous as it uses threads. The only easy fix is to run the app with `ROCKET_WORKERS=1`, but that would result in lower performances and is not a possible solution.
Poster
Owner

fixed by 1cede79b5d

fixed by 1cede79b5db4f463b11423198fe306f439c03d74
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: plume/rocket_i18n#2
Loading…
There is no content yet.