Skip to content

request.raw_post ( env['rack.input'] ) is nil on pitchfork( with rack3) #177

@os0x

Description

@os0x

Describe the bug

gems:

  • pitchfork 0.18.1
  • rack 3.2.3
  • rails 8.0.3

request.raw_post is always nil, and request.env["rack.input"].read is blank.

How to reproduce

Here is my sample app: https://github.com/os0x/rack3_pitchfork_sample

https://github.com/os0x/rack3_pitchfork_sample/blob/main/app/controllers/hello_controller.rb

def index
  puts "params: #{params.inspect}"
  puts "raw_post:", request.raw_post
  puts 'request.env["rack.input"]:', request.env["rack.input"].read
  render json: { message: "Hello, Pitchfork!" }
end

on puma

$ bundle exec rails s (using puma)
and
$ curl -X POST http://localhost:3000/hello -d '{"message": "hello" }'

Started POST "/hello" for ::1 at 2025-10-25 15:17:42 +0900
  ActiveRecord::SchemaMigration Load (0.4ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC /*application='Rack3PitchforkSample'*/
Processing by HelloController#index as */*
  Parameters: {"{\"message\": \"hello\" }" => nil}
params: #<ActionController::Parameters {"{\"message\": \"hello\" }" => nil, "controller" => "hello", "action" => "index"} permitted: false>
raw_post:
{"message": "hello" }
request.env["rack.input"]:
{"message": "hello" }
Completed 200 OK in 20ms (Views: 0.1ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)

raw_post is correct.

on pitchfork

$ WORKER_NUM=1 PORT=3000 bundle exec pitchfork -c pitchfork.conf.rb (use pitchfork)
I send the same request.

I, [2025-10-25T15:18:01.118451 #9156]  INFO -- [Pitchfork]: listening on addr=0.0.0.0:3000 fd=10
I, [2025-10-25T15:18:01.145019 #9156]  INFO -- [Pitchfork]: monitor pid=9156 ready
I, [2025-10-25T15:18:01.145074 #9156]  INFO -- [Pitchfork]: monitor process ready
I, [2025-10-25T15:18:01.145155 #9156]  INFO -- [Pitchfork]: worker=0 gen=0 spawning...
I, [2025-10-25T15:18:01.150503 #9251]  INFO -- [Pitchfork]: worker=0 gen=0 pid=9251 spawned
I, [2025-10-25T15:18:01.150876 #9156]  INFO -- [Pitchfork]: worker=0 gen=0 pid=9251 registered
I, [2025-10-25T15:18:01.150984 #9251]  INFO -- [Pitchfork]: worker=0 gen=0 pid=9251 ready
params: #<ActionController::Parameters {"{\"message\": \"hello\" }" => nil, "controller" => "hello", "action" => "index"} permitted: false>
raw_post:

request.env["rack.input"]:

raw_post is nil.

rack 2 & pitchfork

I, [2025-10-26T14:50:03.077087 #18412]  INFO -- [Pitchfork]: listening on addr=0.0.0.0:3000 fd=10
I, [2025-10-26T14:50:03.109811 #18412]  INFO -- [Pitchfork]: monitor pid=18412 ready
I, [2025-10-26T14:50:03.109865 #18412]  INFO -- [Pitchfork]: monitor process ready
I, [2025-10-26T14:50:03.109948 #18412]  INFO -- [Pitchfork]: worker=0 gen=0 spawning...
I, [2025-10-26T14:50:03.118079 #18628]  INFO -- [Pitchfork]: worker=0 gen=0 pid=18628 spawned
I, [2025-10-26T14:50:03.118425 #18628]  INFO -- [Pitchfork]: worker=0 gen=0 pid=18628 ready
I, [2025-10-26T14:50:03.118533 #18412]  INFO -- [Pitchfork]: worker=0 gen=0 pid=18628 registered
params: #<ActionController::Parameters {"{\"message\": \"hello\" }" => nil, "controller" => "hello", "action" => "index"} permitted: false>
raw_post:
{"message": "hello" }
request.env["rack.input"]:
{"message": "hello" }

raw_post is correct.

How do you advise I can do this? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions