i18next / i18next-express-middleware

[deprecated] can be replaced with i18next-http-middleware
https://github.com/i18next/i18next-http-middleware
MIT License
207 stars 55 forks source link

Concurrent request causes wrong language on server #173

Closed lucasfeliciano closed 5 years ago

lucasfeliciano commented 5 years ago

I'm facing a problem where when my server has concurrent requests when server side rendering sometimes the language is not correct, instead, is the one from the concurrent request.

Diving into the code I saw this part here https://github.com/i18next/i18next-express-middleware/blob/master/src/index.js#L19

Which make me wondering why clone the i18n instance with { initImmediate: false } instead of true.

jamuhl commented 5 years ago

because setting it to false will: https://github.com/i18next/i18next/blob/master/src/i18next.js#L25

makes init call sync on express side - as cloning takes same already loaded translations

lucasfeliciano commented 5 years ago

Thank you for the response. The problem that I had is fixed :)