This project is archived and is in readonly mode.

#2873 ✓ resolved
Hongli Lai

Application reloading should be deferred to end of request, currently interferes with 'render :text => lambda { ... }' streaming

Reported by Hongli Lai | July 6th, 2009 @ 01:19 PM | in 2.3.10

Consider the following:

render :text => lambda { |response, output|

User.each do |user|
  output.write("#{user.username}\n")
end

}

This doesn't work correctly in development mode because AC::Reloader cleans up the application code in an ensure block. However, the lambda passed to 'render :text' is evaluated outside AC::Dispatcher#call, so by the time the lambda is called, the User class has already been cleaned up, resulting in all kinds of "interesting" behavior.

The attached patch for Rails 2.3 defers reloading to the very end of the request, when #close is called on the Rack response body. This makes my above example work correctly.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Tickets have moved to Github

The new ticket tracker is available at https://github.com/rails/rails/issues

Shared Ticket Bins