Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Issue with HTTP streaming and undefined encoding method for StreamingBuffer #12001

Closed
vojtad opened this Issue Aug 23, 2013 · 9 comments

Comments

Projects
None yet
8 participants

vojtad commented Aug 23, 2013

Does anyone have issue with error undefined method `encoding' for #ActionView::StreamingBuffer:0x0000000533a130 with enabled HTTP streaming? Here is whole callstack:

ActionView::Template::Error (undefined method `encoding' for #<ActionView::StreamingBuffer:0x0000000533a130>):
    57: 
    58: <% cache_unless user_signed_in?, ['header'] do %>
    59:     <header id="sl-fixedHeader">
    60:       <%= link_to root_path, :id => 'sl-header-logo' do %>
    61:           <div id="sl-header-logoImage"></div>
    62:       <% end %>
    63: 
  /home/vojta/.gem/ruby/2.0.0/bundler/gems/rails-998d9c89e42d/actionview/lib/action_view/helpers/capture_helper.rb:197:in `with_output_buffer'
  /home/vojta/.gem/ruby/2.0.0/bundler/gems/rails-998d9c89e42d/actionview/lib/action_view/helpers/capture_helper.rb:38:in `capture'
  /home/vojta/.gem/ruby/2.0.0/bundler/gems/rails-998d9c89e42d/actionview/lib/action_view/helpers/tag_helper.rb:97:in `content_tag'
  /home/vojta/.gem/ruby/2.0.0/bundler/gems/rails-998d9c89e42d/actionview/lib/action_view/helpers/url_helper.rb:183:in `link_to'
  /home/vojta/dev/sl/sl_web_ruby/app/views/layouts/application.html.erb:60:in `block in _app_views_layouts_application_html_erb___108349764833722706_47082760'
  /home/vojta/.gem/ruby/2.0.0/bundler/gems/rails-998d9c89e42d/actionview/lib/action_view/helpers/cache_helper.rb:133:in `cache_if'
  /home/vojta/.gem/ruby/2.0.0/bundler/gems/rails-998d9c89e42d/actionview/lib/action_view/helpers/cache_helper.rb:146:in `cache_unless'
  /home/vojta/dev/sl/sl_web_ruby/app/views/layouts/application.html.erb:58:in `_app_views_layouts_application_html_erb___108349764833722706_47082760'
  /home/vojta/.gem/ruby/2.0.0/bundler/gems/rails-998d9c89e42d/actionview/lib/action_view/template.rb:143:in `block in render'
  /home/vojta/.gem/ruby/2.0.0/bundler/gems/rails-998d9c89e42d/activesupport/lib/active_support/notifications.rb:161:in `instrument'
  /home/vojta/.gem/ruby/2.0.0/bundler/gems/rails-998d9c89e42d/actionview/lib/action_view/template.rb:337:in `instrument'
  /home/vojta/.gem/ruby/2.0.0/bundler/gems/rails-998d9c89e42d/actionview/lib/action_view/template.rb:141:in `render'
  /home/vojta/.gem/ruby/2.0.0/bundler/gems/rails-998d9c89e42d/actionview/lib/action_view/renderer/streaming_template_renderer.rb:70:in `block (2 levels) in delayed_render'

When I comment out the line calling encoding on output_buffer in capture_helper.rb everything works like a charm. I've tried rails 4.0.0, 4.0-stable branch and also master.

Member

robin850 commented Aug 24, 2013

@vojtad : Could you please provide us an example application or at least a way to reproduce it? It would really help us to debug.

I am running into this trouble too. Just used "content_for". I have no idea what parts of code I need to show you to reproduce this error. To reproduce it for sure a whole application could be sent, but I am working under the non-disclosure agreement.

vojtad commented Apr 16, 2014

I guess it is problem in link_to call according to callstack in my first post. I just turned http streaming off back when I ran to this error. I will try to test it on latest rails and if the problem persists I will create minimal application to reproduce it as soon as I will have some time.

StreamingBuffer (used when streaming) does not inherit from String, like OutputBuffer does, so the encoding method that is being called does not exist.

vojtad commented May 13, 2014

I have tried to enable http streaming on our website yesterday and everything is working like a charm, now. However, I do not know if the problem was fixed in rails or whether it is fixed thanks to changes on our website.

Owner

rafaelfranca commented May 13, 2014

I'm closing until we have more information of how to reproduce it.

I just ran into this problem too, and was able to reproduce it on 4.1.6. I've narrowed it down to using link_to (actually, anything that uses capture) with a block given, in the app layout.

I've made a test app demonstrating the bug here: https://github.com/keichan34/streamingbuffer_encoding_testapp

@rafaelfranca rafaelfranca reopened this Sep 17, 2014

Rush commented Nov 15, 2014

Applies to rails from master, 4.2-beta:

[rails] ActionView::Template::Error (undefined method `encoding' for #<ActionView::StreamingBuffer:0x000000066d96f0>):
[rails]     22:     .container.main
[rails]     23:       .row.header
[rails]     24:         .menu.col-md-3.hidden-xs.hidden-sm
[rails]     25:           = link_to machines_path do
[rails]     26:             = image_tag 'logo/virtkick-logo-pixelart-64.png'
[rails]     27: 
[rails]     28:         .header.col-md-6
[rails]   gems/rails-4b4dca48a590/actionview/lib/action_view/helpers/capture_helper.rb:197:in `with_output_buffer'
[rails]   gems/rails-4b4dca48a590/actionview/lib/action_view/helpers/capture_helper.rb:38:in `capture'
[rails]   gems/rails-4b4dca48a590/actionview/lib/action_view/helpers/tag_helper.rb:106:in `content_tag'
[rails]   gems/requirejs-rails-119538b99374/app/helpers/requirejs_helper.rb:89:in `content_tag'
[rails]   gems/rails-4b4dca48a590/actionview/lib/action_view/helpers/url_helper.rb:184:in `link_to'
[rails]   /home/rush/virtkick/webapp/app/views/layouts/application.html.slim:25:in `_app_views_layouts_application_html_slim___4212512654913348578_54040740'
[rails]   /home/rush/virtkick/.rvm/gems/ruby-2.1.3/bundler/gems/rails-4b4dca48a590/actionview/lib/action_view/template.rb:145:in `block in render'
[rails]   /home/rush/virtkick/.rvm/gems/ruby-2.1.3/bundler/gems/rails-4b4dca48a590/activesupport/lib/active_support/notifications.rb:166:in `instrument'
[rails]   /home/rush/virtkick/.rvm/gems/ruby-2.1.3/bundler/gems/rails-4b4dca48a590/actionview/lib/action_view/template.rb:333:in `instrument'
[rails]   /home/rush/virtkick/.rvm/gems/ruby-2.1.3/bundler/gems/rails-4b4dca48a590/actionview/lib/action_view/template.rb:143:in `render'
[rails]   /home/rush/virtkick/.rvm/gems/ruby-2.1.3/bundler/gems/rails-4b4dca48a590/actionview/lib/action_view/renderer/streaming_template_renderer.rb:70:in `block (2 levels) in delayed_render'

Gonzih commented Feb 9, 2015

Have same issue with rails 4.2. Is there a fix for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment