Add support for rack.response_finished (#3681)#9
Open
MitchLewis930 wants to merge 1 commit intopr_059_beforefrom
Open
Add support for rack.response_finished (#3681)#9MitchLewis930 wants to merge 1 commit intopr_059_beforefrom
rack.response_finished (#3681)#9MitchLewis930 wants to merge 1 commit intopr_059_beforefrom
Conversation
* Add support for `rack.response_finished` It is very similar to `rack.after_reply`, but is part of the Rack spec. It can't just be an alias because the spec state it has to invoke callbacks in reverse order. Fix: puma#3631 Ref: rack/rack#1777 Ref: rack/rack#1802 Co-Authored-By: Robert Laurin <robert.laurin@shopify.com> * request.rb - more rename `e` to `error` changes --------- Co-authored-by: Robert Laurin <robert.laurin@shopify.com> Co-authored-by: MSP-Greg <Greg.mpls@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR_059
Note
Medium Risk
Touches the core request lifecycle by adding new ensure-time callbacks and propagating
status/headers/error, which could affect edge cases (async/hijack/shutdown) if assumptions about variable initialization or ordering are wrong.Overview
Adds a new Rack env extension,
rack.response_finished, surfaced viaPuma::Const::RACK_RESPONSE_FINISHEDand initialized in the binder/request env.handle_requestnow captures any exception raised by the Rack app and, in anensureblock, invokesrack.response_finishedcallbacks in reverse order with(env, status, headers, error), swallowing/logging callback errors.Tests are updated to run with a null log writer and to assert callback ordering and that the hook fires both on normal responses and when the app raises (receiving the 500 status and the original exception).
Written by Cursor Bugbot for commit 1b08ed7. This will update automatically on new commits. Configure here.