Skip to content

Remove to_ary from RackBody#44953

Merged
kamipo merged 1 commit intorails:mainfrom
skipkayhil:rm-rackbody-toary
Apr 25, 2022
Merged

Remove to_ary from RackBody#44953
kamipo merged 1 commit intorails:mainfrom
skipkayhil:rm-rackbody-toary

Conversation

@skipkayhil
Copy link
Copy Markdown
Member

Summary

It was added in 66f8997 to be compatible with Rack::ContentLength.
However, to_ary was removed from Rack::Response in 2.1.0, and
Rack::ContentLength stopped checking for response bodies to define
to_ary in 2.2.0. In addition, Rack 3 will eventually require response
bodies that define to_ary to have a proper return value.

Since the minimum supported Rack version is already 2.2.0, to_ary can
be safely removed now.

Other Information

It was added in 66f8997 to be compatible with Rack::ContentLength.
However, to_ary was removed from Rack::Response in 2.1.0, and
Rack::ContentLength stopped checking for response bodies to define
to_ary in 2.2.0. In addition, Rack 3 will eventually require response
bodies that define to_ary to have a proper return value.

Since the minimum supported Rack version is already 2.2.0, to_ary can
be safely removed now.
@ioquatix
Copy link
Copy Markdown
Contributor

Thanks for doing this!

tenderlove pushed a commit that referenced this pull request Sep 23, 2022
zzak added a commit to zzak/rails that referenced this pull request Oct 13, 2023
There is an inherit complexity with wrapping the Rack body inside Rails which can lead to bugs, like rails#49588.

While rails#49616 fixed the bug, it's probably not a good long-term solution.

If we go all the way back to 6a89850, we can see this was the original behavior. However, we were trying to solve a separate issue with streaming bodies during disconnect.

The `live_stream_test#test_abort_with_full_buffer` test fails in this PR, but I wanted to raise that maybe this could be handled a different way.

Also there are two failures in `response_test` which are questions to me:

* `ResponseTest#test_[response.to_a].flatten_does_not_recurse_infinitely`
* `ResponseTest#test_compatibility_with_Rack::ContentLength`

The first seems it is actually resolved upstream, per this comment:
rails#47092 (comment)

The second means we broke `Rack::ContentLength` and there is a bit on this in rails#44953.

FWIW: I'm not proposing this PR exactly, but looking for a path forward and would love some feedback. 🙇
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants