Skip to content

Rack 3.1+ is breaking message_bus #373

@arrowcircle

Description

@arrowcircle

Hi! I tried to update my rails app to rack 3.1+ and got the log full of errors like this:

Started POST "/message-bus/3962c9a2-1f6a-4a7b-9958-ee74004764e0/poll" for ::1 at 2025-12-27 22:46:31 +0100
Delivering backlog [#<struct MessageBus::Message global_id=-1, message_id=-1, channel="/__status", data={"/channel" => 0}>] to client 3962c9a2-1f6a-4a7b-9958-ee74004764e0 for user
Started POST "/message-bus/3962c9a2-1f6a-4a7b-9958-ee74004764e0/poll" for ::1 at 2025-12-27 22:46:31 +0100
Delivering backlog [#<struct MessageBus::Message global_id=-1, message_id=-1, channel="/__status", data={"/channel" => 0}>] to client 3962c9a2-1f6a-4a7b-9958-ee74004764e0 for user

With rack < 3.1 I see this in logs and everything works perfectly:

Started POST "/message-bus/801112c9-3472-47d6-9bec-f13b88f5ab42/poll" for ::1 at 2025-12-27 22:45:13 +0100
Delivering messages [{"global_id":-1,"message_id":-1,"channel":"/__status","data":{"/channel":0}}] to client 801112c9-3472-47d6-9bec-f13b88f5ab42 for user  (chunked)

I used ruby client and also tried with python client.

How can I find out what is the problem and fix it?
PS. More curl details

Rack 3.1:

curl -v --no-buffer --http1.1 \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data "/__status=-1" \
  "http://localhost:3000/message-bus/TEST-CLIENT-ID/poll"
* Host localhost:3000 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:3000...
* Connected to localhost (::1) port 3000
> POST /message-bus/TEST-CLIENT-ID/poll HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/8.7.1
> Accept: */*
> Content-Type: application/x-www-form-urlencoded
> Content-Length: 12
>
* upload completely sent off: 12 bytes
< HTTP/1.1 200 OK
< cache-control: must-revalidate, private, max-age=0
< content-type: application/json; charset=utf-8
< pragma: no-cache
< expires: 0
< access-control-allow-origin: *
< x-request-id: 264c6310-e28b-4648-86ac-91eeb5e4f975
< x-runtime: 0.005298
< server-timing:
< content-length: 79
<
[{"global_id":-1,"message_id":-1,"channel":"/__status","data":{"/__status":0}}]* Connection #0 to host localhost left intact

Rack 3:

curl -v --no-buffer --http1.1 \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data "/__status=-1" \
  "http://localhost:3000/message-bus/TEST-CLIENT-ID/poll"
* Host localhost:3000 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:3000...
* Connected to localhost (::1) port 3000
> POST /message-bus/TEST-CLIENT-ID/poll HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/8.7.1
> Accept: */*
> Content-Type: application/x-www-form-urlencoded
> Content-Length: 12
>
* upload completely sent off: 12 bytes
< HTTP/1.1 200 OK
< Cache-Control: must-revalidate, private, max-age=0
< Pragma: no-cache
< Expires: 0
< Access-Control-Allow-Origin: *
< Connection: close
< Content-Type: text/plain; charset=utf-8
< Transfer-Encoding: chunked
< X-Content-Type-Options: nosniff
<
[{"global_id":-1,"message_id":-1,"channel":"/__status","data":{"/__status":0}}]
|

and keeps waiting for new data.

PS1. I tracked it down to rack 3.1 release, which deprecated chuned-encoding. https://github.com/rack/rack/blob/main/CHANGELOG.md#310---2024-06-11

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