Released Gon v7.0.0
Source: Dev.to
Release v7.0.0
Gon v7.0.0 release – this major version bump introduces breaking changes.
Breaking change: request_store is now optional
The dependency on request_store has been removed. Gon now prefers ActiveSupport::CurrentAttributes when it is available.
Background
- Previously, assigning a value such as
gon.foo = 'bar'stored the value internally usingrequest_store. - Since Rails 5.2, Rails provides the official alternative ActiveSupport::CurrentAttributes.
request_storerelies onThread#[], which actually uses fiber‑local variables. This can cause incorrect behavior when execution switches to another Fiber.- Early versions of
ActiveSupport::CurrentAttributesalso used fiber‑local storage, but starting with Rails 7.0 it automatically switches between fiber‑local and thread‑local storage depending on the server type, making it more stable.
New behavior
| Condition | Gon’s storage mechanism |
|---|---|
Rails 5.2+ and ActiveSupport::CurrentAttributes is available | ActiveSupport::CurrentAttributes (automatic) |
| Otherwise | request_store (must be added explicitly) |
If you need to use request_store with older Rails versions, add it to your Gemfile:
# Gemfile
gem 'request_store'
What to do
- For most modern Rails applications (Rails 5.2+), no changes are required—Gon will automatically use
ActiveSupport::CurrentAttributes. - If you encounter any issues or rely on the old behavior, let the maintainers know.