undefined method `rewind' for an instance of Rackup::Handler::WEBrick::Input
Hey!
I'm trying to use rails_api_logger with my webrick-based rails app but when request comes in, app raises:
[2025-03-31 16:13:58] ERROR NoMethodError: undefined method `rewind' for an instance of Rackup::Handler::WEBrick::Input
/Users/mbajur/.local/share/mise/installs/ruby/3.3.3/lib/ruby/gems/3.3.0/bundler/gems/rails_api_logger-f787839b5d4a/app/middlewares/rails_api_logger/middleware.rb:23:in `call'
I managed to fix that by changing this line to request.body.rewind if request.body.respond_to?(:rewind)
I can open a PR if you think that's a proper fix for the issue.
I'm on Ruby 3.3.3 and Rails 7.1.3.2
Actually, it seems that after that change, RAL is not saving response status code nor body with InboundRequestLog
I think this is related to the fact that Rack 3.0 bodies are not rewindable per default anymore. See Rack::RewindableInput::Middleware.
@coorasse are you using this gem anywhere with Rack 3.0 successfully?
Yes, we use it in at least two apps with rack 3+
@mbajur do you still have the issue after switching to puma?
The issue is fixed now on webrick as well