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

Ensure Rack::ContentLength is loaded as middleware #4541

Merged

Conversation

f3ndot
Copy link
Contributor

@f3ndot f3ndot commented Apr 22, 2020

6.0.5 removed Sidekiq::WebApplication's own Content-Length header calculation, expecting Rack to do it instead via some middleware (675e40c). This was to fix an issue where New Relic would inject content into Sidekiq's Web UI after the hand crafted content length was calculated (#4440). While such middleware exists, it's not enabled by default (at least in a Rails app) and so the HTTP response doesn't have the header at all.

The absence of the header has caused unexpected behaviour in an nginx and HAProxy setup we use in production systems, causing each page load to take exactly 20 seconds. The suspicion is that, without the Content-Length response header, HAProxy waits a preset amount of time before deciding the body must have surely by finished and then responds.

@mperham
Copy link
Collaborator

mperham commented Apr 22, 2020

Looks good. Please add a changelog entry.

6.0.5 removed Sidekiq::WebApplication's own Content-Length header calculation, expecting Rack to do it instead via some middleware. This was to fix an issue where New Relic would inject content into Sidekiq's Web UI after the hand crafted content length was calculated. While such middleware exists, it's not enabled by default (at least in a Rails app) and so the HTTP response doesn't have the header at all.

The absence of the header has caused unexpected behaviour in an nginx and HAProxy setup, causing each page load to take exactly 20 seconds. The suspicion is that, without the Content-Length response header, HAProxy waits a preset amount of time before deciding the body must have surely been finished and then reponds.
@f3ndot f3ndot force-pushed the ensure-rack-content-length-middleware branch from 7dd6273 to b07e99d Compare April 22, 2020 21:01
@f3ndot
Copy link
Contributor Author

f3ndot commented Apr 22, 2020

@mperham all set. Thanks for your review.

@mperham mperham merged commit 8960ecb into sidekiq:master Apr 22, 2020
@f3ndot f3ndot deleted the ensure-rack-content-length-middleware branch April 23, 2020 21:01
@mperham
Copy link
Collaborator

mperham commented Feb 24, 2021

The next version of Sidekiq will revert this as I see Content-Length as orthogonal to the Web UI. I believe Rails will handle it automatically. If you are running the Web UI directly, you can ‘use Rack::ContentLength’ beforehand. If neither of these is applicable, let me know and we can figure out something.

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.

None yet

2 participants