Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Rack::ContentLength from being loaded outside of Rails #10331

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

mitchellhenke
Copy link
Contributor

🛠 Summary of changes

This fix is tied to the issues in #10304 / #10318. RequestStore depends on Rack::BodyProxy, which depends on the close method being called on the body so it can run the callbacks. Mysteriously, this wasn't happening, which caused RequestStore to not clean up after a request.

After digging a bit and removing as many Rack middlewares as possible and seeing what might causes the change in behavior, the culprit seems to be use Rack::ContentLength being called outside the Rails application. In testing this change, Content-Length is returned regardless due to the web server rather than application server handling it, and there should be no impact. I tested RequestStore a bit and it seemed to behave as expected with this change.

The issue was present when using both Puma and WEBrick since they both rely on being able to call close on the body (Puma, WEBrick). I couldn't validate Passenger locally due to phusion/passenger#2508, but I suspect the result would be similar.

changelog: Internal, Bug Fix, Remove Rack::ContentLength from being loaded outside of Rails
@mitchellhenke mitchellhenke requested a review from a team March 28, 2024 14:35
@mitchellhenke mitchellhenke merged commit 3c2bad4 into main Mar 28, 2024
2 checks passed
@mitchellhenke mitchellhenke deleted the mitchellhenke/remove-non-rails-rack-length branch March 28, 2024 15:50
@aduth aduth mentioned this pull request Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants