render stream: true fails => undef `to_str' for Rack::Chunked::Body #5027

Closed
krainboltgreene opened this Issue Feb 13, 2012 · 3 comments

Projects

None yet

3 participants

Here's the setup:

class PagesController < ApplicationController
  before_filter -> { @footer = true }

  caches_action :splash

  def splash
    render stream: true
  end
-----> Installing dependencies using Bundler version 1.1.rc.7
       Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
       Using rake (0.9.2.2)
       Using i18n (0.6.0)
       Using multi_json (1.0.4)
       Using activesupport (3.2.1)
       Using builder (3.0.0)
       Using activemodel (3.2.1)
       Using erubis (2.7.0)
       Using journey (1.0.1)
       Using rack (1.4.1)
       Using rack-cache (1.1)
       Using rack-test (0.6.1)
       Using hike (1.2.1)
       Using tilt (1.3.3)
       Using sprockets (2.1.2)
       Using actionpack (3.2.1)
       Using mime-types (1.17.2)
       Using polyglot (0.3.3)
       Using treetop (1.4.10)
       Using mail (2.4.1)
       Using actionmailer (3.2.1)
       Using arel (3.0.0)
       Using tzinfo (0.3.31)
       Using activerecord (3.2.1)
       Using activeresource (3.2.1)
       Using addressable (2.2.6)
       Using bcrypt-ruby (3.0.1)
       Using bson (1.5.2)
       Using bson_ext (1.5.2)
       Using coffee-script-source (1.2.0)
       Using execjs (1.3.0)
       Using coffee-script (2.2.0)
       Using rack-ssl (1.3.2)
       Using json (1.6.5)
       Using rdoc (3.12)
       Using thor (0.14.6)
       Using railties (3.2.1)
       Using coffee-rails (3.2.2)
       Using daemons (1.1.8)
       Using dalli (1.1.4)
       Using draper (0.10.0)
       Using eventmachine (0.12.10)
       Using multipart-post (1.1.4)
       Using faraday (0.7.6)
       Using jquery-rails (2.0.0)
       Using mongo (1.5.2)
       Using mongoid (2.4.3)
       Using newrelic_rpm (3.3.1)
       Using oauth (0.4.5)
       Using oauth2 (0.5.2)
       Using bundler (1.1.rc.7)
       Using rails (3.2.1)
       Using sass (3.1.15)
       Using sass-rails (3.2.4)
       Using temple (0.3.5)
       Using slim (1.1.0)
       Using slim-rails (1.0.3)
       Using sorcery (0.7.6)
       Using thin (1.3.1)
       Using uglifier (1.2.3)
2012-02-13T18:11:14+00:00 app[web.1]: Started GET "/" for 208.117.193.99 at 2012-02-13 18:11:14 +0000
2012-02-13T18:11:14+00:00 app[web.1]: 
2012-02-13T18:11:14+00:00 app[web.1]: NoMethodError (undefined method `to_str' for #<Rack::Chunked::Body:0x000000028ffe88>):
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/caching/fragments.rb:62:in `block in write_fragment'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/caching/fragments.rb:123:in `block in instrument_fragment_cache'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/notifications.rb:123:in `block in instrument'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/notifications.rb:123:in `instrument'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/caching/fragments.rb:123:in `instrument_fragment_cache'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/caching/fragments.rb:61:in `write_fragment'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/caching/actions.rb:109:in `_save_fragment'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/caching/actions.rb:147:in `filter'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:321:in `around'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:310:in `_callback_around_56'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_66'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:436:in `_run__3580495302427494058__process_action__2983193010779220199__callbacks'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `__run_callback'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/abstract_controller/callbacks.rb:17:in `process_action'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/metal/rescue.rb:29:in `process_action'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/notifications.rb:123:in `block in instrument'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/notifications.rb:123:in `instrument'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.3.1/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:in `block in process_action'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.3.1/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:255:in `block in perform_action_with_newrelic_trace'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.3.1/lib/new_relic/agent/method_tracer.rb:242:in `trace_execution_scoped'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.3.1/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:250:in `perform_action_with_newrelic_trace'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.3.1/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:in `process_action'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/abstract_controller/base.rb:121:in `process'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/abstract_controller/rendering.rb:45:in `process'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/metal.rb:203:in `dispatch'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_controller/metal.rb:246:in `block in action'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:66:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:66:in `dispatch'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:30:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/journey-1.0.1/lib/journey/router.rb:68:in `block in call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/journey-1.0.1/lib/journey/router.rb:56:in `each'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/journey-1.0.1/lib/journey/router.rb:56:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:589:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.3.1/lib/new_relic/rack/browser_monitoring.rb:23:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-2.4.3/lib/rack/mongoid/middleware/identity_map.rb:33:in `block in call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-2.4.3/lib/mongoid.rb:132:in `unit_of_work'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-2.4.3/lib/rack/mongoid/middleware/identity_map.rb:33:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/conditionalget.rb:25:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/head.rb:14:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/flash.rb:242:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/cookies.rb:338:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `_run__2817706704028173152__call__4532870903455771305__callbacks'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `__run_callback'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/sendfile.rb:102:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/logger.rb:26:in `call_app'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/logger.rb:16:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/request_id.rb:22:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/static.rb:53:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:132:in `forward'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:241:in `fetch'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:181:in `lookup'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:65:in `call!'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:50:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/engine.rb:479:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/application.rb:220:in `call'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/connection.rb:80:in `block in pre_process'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/connection.rb:78:in `catch'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/connection.rb:78:in `pre_process'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/connection.rb:53:in `process'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/connection.rb:38:in `receive_data'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/backends/base.rb:61:in `start'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/server.rb:159:in `start'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/controllers/controller.rb:86:in `start'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/runner.rb:185:in `run_command'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/runner.rb:151:in `run!'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/bin/thin:6:in `<top (required)>'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/bin/thin:19:in `load'
2012-02-13T18:11:14+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/bin/thin:19:in `<main>'
2012-02-13T18:11:14+00:00 app[web.1]: 
2012-02-13T18:11:14+00:00 app[web.1]: 
2012-02-13T18:11:14+00:00 app[web.1]: cache: [GET /] miss
Contributor
kennyj commented Feb 14, 2012

I could reproduce this issue (I used production environment). But, I think that this issue is difficult.
Because, You want to use cache and stream.

If you cache some fragments, you have to take perfectly rendered string.
But If you use stream, Rails assign Rack::Chunked::Body to respond_body, and this is not perfectly rendered string.

When we use stream, should we cache fragments ?
What do you think ?

Being able to cache the <head> of the view and send it along first certainly seems like a good idea.

However, I'm more inclined to simply not cache the head and use stream, if it doesn't work.

Owner

Please let me know if my patch works for you guys

@arunagw arunagw pushed a commit to arunagw/rails that referenced this issue Feb 16, 2012
@spastorino spastorino Rack body respond to each and not to join
This fixes undef `to_str' for Rack::Chunked::Body when using
caches_action + streaming on an action

Closes #5027
7c79996
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment