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

Server crashes when using gzip compression #32

Open
floriandejonckheere opened this issue Aug 31, 2023 · 0 comments
Open

Server crashes when using gzip compression #32

floriandejonckheere opened this issue Aug 31, 2023 · 0 comments

Comments

@floriandejonckheere
Copy link

Tipi's Rack adapter crashes when a request with Accept-Encoding: gzip is handled:

/usr/local/bundle/gems/tipi-0.55/lib/tipi/rack_adapter.rb:28:in `respond': undefined method `first' for #<Rack::Deflater::GzipStream:0x00007f6c78931930 @body=#<Rack::BodyProxy:0x00007f6c78932a10 @body=["Not Found\n"], @block=#<Proc:0x00007f6c78932920 /usr/local/bundle/gems/rack-3.0.8/lib/rack/common_logger.rb:45>, @closed=false>, @mtime=nil, @sync=true> (NoMethodError)

            body.first
                ^^^^^^
	from /usr/local/bundle/gems/tipi-0.55/lib/tipi/rack_adapter.rb:9:in `block in run'
	from /usr/local/bundle/gems/tipi-0.55/lib/tipi/http1_adapter.rb:52:in `handle_request'
	from /usr/local/bundle/gems/tipi-0.55/lib/tipi/http1_adapter.rb:28:in `each'
	from /usr/local/bundle/gems/tipi-0.55/lib/tipi.rb:50:in `client_loop'
	from /usr/local/bundle/gems/tipi-0.55/lib/tipi.rb:41:in `block (2 levels) in accept_loop'
/srv # bundle exec ruby tipi.rb
Starting metrics server on 0.0.0.0:9394
/usr/local/bundle/gems/tipi-0.55/lib/tipi/rack_adapter.rb:28:in `respond': undefined method `first' for #<Rack::Deflater::GzipStream:0x00007fc887ff7768 @body=#<Rack::BodyProxy:0x00007fc887ff7cb8 @body=["Not Found\n"], @block=#<Proc:0x00007fc887ff7c68 /usr/local/bundle/gems/rack-3.0.8/lib/rack/common_logger.rb:45>, @closed=false>, @mtime=nil, @sync=true> (NoMethodError)

The code I was using at the moment:

require "tipi"
require "yabeda"
require "yabeda/prometheus"

Tipi.serve(
  "0.0.0.0",
  9394,
  { reuse_addr: true, dont_linger: true },
  &Tipi::RackAdapter.run(Yabeda::Prometheus::Exporter.rack_app)
)

The request that triggers the crash:

curl -sH 'Accept-Encoding: gzip' localhost:9394

The problem seems to be that Tipi::RackAdapter receives the Rack::BodyProxy object wrapped in a Rack::Deflater::GzipStream when compression is requested.

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

No branches or pull requests

1 participant