Skip to content

Commit

Permalink
Rails 7.1 Incompatibility: Payload exclude locals
Browse files Browse the repository at this point in the history
Inspired by @abrom in #203:

"I've been doing some digging and have found the cause of the SystemStackError being raised when trying to using meta_request with Rails 7.1.x

In short it comes down to a change in the instrumentation mechanism to include locals:

rails/rails@b451ff0#diff-c92c886291bac7b41bab2a3a884a476ff8edfe2827da7db5ee0bf78c9ad8a17fR250

The problem being that meta_request tries to serialise the render payload to JSON, however the template property of the ActionView objects (if passed through the locals when rendering a template) has cyclic child dependencies (the routes) which can not be serialised.

The simple fix would be to exclude that key (locals) in the serialisation to revert the behaviour to pre-Rails 7.1.x as such: payload.except(:locals)"
  • Loading branch information
kbruccoleri committed Aug 27, 2024
1 parent dedbe2a commit 992de8a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion meta_request/lib/meta_request/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def sanitize_hash(payload)
payload[:key] = ActiveSupport::Cache::Store.new.send(:normalize_key, payload[:key])
end

payload
payload.except(:locals)
end

def not_encodable?(value)
Expand Down

0 comments on commit 992de8a

Please sign in to comment.