AlchemyCMS / alchemy_cms

Alchemy is the Open Source Rails CMS framework for the component based web that can be used as classic server side rendered or headless CMS.
https://www.alchemy-cms.com
BSD 3-Clause "New" or "Revised" License
846 stars 315 forks source link

Language setting problems with thread local variables #623

Closed tbuehlmann closed 10 years ago

tbuehlmann commented 10 years ago

So, we had problems (which are too heavy to describe in length) with Language settings and figured out that it likely had to do with the threaded web application server (Puma) we are using. The actual reason for this was the use of thread local variables, as in here:

After replacing the Thread locals with RequestStore (https://github.com/steveklabnik/request_store) variables, the problems disappeared.

I highly recommend against using Thread locals in the way it is done right now and suggest using something like RequestStore. If there's interest I'd write down a PR for it.

tvdeyen commented 10 years ago

Ok. RequestStore simply ensures to clear out the Thread variable on each request. Simple and clear. Nice.

Yes, we should use it to avoid concurrency problems.

Please send a pull request that solves this.

Thanks for pointing that one out.

mamhoff commented 10 years ago

We had this issue with unicorn, as well, and I hacked it badly to work. Pretty please: PR :) :+1:

tbuehlmann commented 10 years ago

I will close this one as the PR is open: https://github.com/magiclabs/alchemy_cms/pull/625