You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The test will just hang forever. This is because under the hood when streaming responses with ActionController::Live we are adding the responses to a SizedQueue with size 10. In a real context, the browser will consume the data as soon as it is generated thus freeing space in the queue; in a rack test context, however, we are expecting the whole response to be returned without actually consuming it as it is processed. So if the test includes more than 10 writes on the stream, the tests will hang forever.
I can see three possible solutions:
Disable streaming in test environments
Substitute the SizedQueue with an infinite Queue in test environments
Consume the response in async.
The third option is arguably the best solution, but it is also the most complex one. I'm also not sure where it should be implemented, it could require changes in the rack-test gem.
Any other thoughts?
System configuration
Rails version:
Lastest master (Rails 5.2.0.beta2) at the time of writing. Commit: a88eb9087260cca256c6faba40bf538d4a0289b3 Ruby version:
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 5-1-stable branch or on master, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.
This is a deeper and more correct report of #31200 after some deep investigation of the issue.
Steps to reproduce
In a new rails application generate a controller and implement it like follows:
Then run the controller test
Expected behavior
The test should succeed
Actual behavior
The test will just hang forever. This is because under the hood when streaming responses with
ActionController::Live
we are adding the responses to aSizedQueue
with size10
. In a real context, the browser will consume the data as soon as it is generated thus freeing space in the queue; in a rack test context, however, we are expecting the whole response to be returned without actually consuming it as it is processed. So if the test includes more than10
writes on the stream, the tests will hang forever.I can see three possible solutions:
SizedQueue
with an infiniteQueue
in test environmentsThe third option is arguably the best solution, but it is also the most complex one. I'm also not sure where it should be implemented, it could require changes in the
rack-test
gem.Any other thoughts?
System configuration
Rails version:
Lastest master (Rails 5.2.0.beta2) at the time of writing. Commit:
a88eb9087260cca256c6faba40bf538d4a0289b3
Ruby version:
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
The text was updated successfully, but these errors were encountered: