aralroca / next-translate

Next.js plugin + i18n API for Next.js 🌍 - Load page translations and use them in an easy way!
MIT License
2.64k stars 206 forks source link

locales getting mixed on simultaneous requests #1219

Open piyush96arora1 opened 3 months ago

piyush96arora1 commented 3 months ago

What version of this package are you using? 2.0.1

What operating system, Node.js, and npm version? node 16.20.0 npm 8.19.4 next 13.4.19

What happened? locales of pages getting mixed. This issue could be also replicated in demo project(next-vernac)clone git@github.com:aralroca/next-translate.git Make a server component and add any promise to it as below import useTranslation from "next-translate/useTranslation";

export default async function Title() { const { t, lang } = useTranslation("common"); const res = await delay(); return ( <>

{t("title")}

</>

); }

function delay() { return new Promise((resolve, reject) => { setTimeout(() => { resolve(1); }, 0.8); }); }

Now call this title in page.js.

Simultaneously hit two locales of this page(localhost:3000 and localhost:3000/es) fastly. To hit 2 request at same time on local i did following one request from browser and one using script, the lcoales will get mixed on english page spanish will be visible

What did you expect to happen? The locales should remain same.

Are you willing to submit a pull request to fix this bug? no

cassus commented 3 months ago

Thanks for reporting! I just bumped into the same issue while playwright testing using concurrent workers.

I'm happy to provide more details if it helps to debug and fix this issue

piyush96arora1 commented 4 weeks ago

Any solution you found? Any updates? @cassus

cassus commented 4 weeks ago

Hi, the workarounds I found was adding retries to our playwright tests or using the built version of our app to run the tests instead of the dev server

piyush96arora1 commented 1 week ago

Any one else faced?