system stack too deep when rendering any default html action.
I downgraded to rails 5.01. It still doesn't work.
seems to be related to ruby 2.4.1.
Error msg below:
SystemStackError (stack level too deep):
I just fired up a brand-new Rails 5.1 project (with Ruby 2.2.5) and was able to use Wicked PDF (1.1.0) without any issues.
I then installed Ruby 2.4.1 and re-bundled and again it is working fine for me. Do you have something else in your view that could be causing this, perhaps a partial that renders a partial, or a method that gets called too many times?
I've run into code that actually isn't recursive, but calls are repeated too many times triggering a SystemStackError.
I've updated the issue title to more accurately reflect what you are experiencing. I wouldn't want people to be incorrectly think it doesn't work at all with 5.1.
Let me know how it goes!
Hi Unixmonkey,
Thank you very much for looking into this issue.
I upgraded to the most recent version of wicked_pdf from rubugems.org everything now works perfect.
I was using an old version of it. Now I am closing this issue.
I'm having the same issue on any route in the app. Using Rails 5.0.2, Ruby 2.4.0.
Here is a part of the stack trace https://gist.github.com/beydogan/f88a81cbead9d20ae65e932f88d6e40d
UPDATE: removing remotipart seems to be working. Its probably related to that remotipart.
@beydogan We've had a documented conflict with Remotipart in #111, but I thought that was fixed in Rails 5+ after #574 was merged.
I'd be curious if you could figure out if that patch isn't helping for some reason.
Also, I think you might be able to change render pdf: 'mypdf' to render_with_wicked_pdf pdf: 'mypdf' to coexist peacefully with Remotipart, but could be wrong. Please let me know!
@unixmonkey I will try with render_with_wicked_pdf but its throwing the exception even I visit a path that doesn't have render pdf
I am also experiencing this issue. Rails 5.1.4 on Ruby 2.4.1
It completely stops the app from loading. It won't load a single page, even one that has nothing to do with PDF generation.
I'm using the latest versions of both remotipart and wickedpdf:
wicked_pdf (1.1.0)
remotipart (1.3.1)
Stack Trace:
Started GET "/" for 10.1.1.12 at 2017-10-18 15:51:23 +1030
15:51:23 web.1 | Chewy request strategy is `atomic`
15:51:23 web.1 | Cannot render console from 10.1.1.12! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
15:51:23 web.1 | (0.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
15:51:23 web.1 | Processing by ProjectsController#index as HTML
15:51:23 web.1 | User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
15:51:24 web.1 | Completed 500 Internal Server Error in 323ms (ActiveRecord: 148.3ms)
15:51:24 web.1 |
15:51:24 web.1 |
15:51:24 web.1 |
15:51:24 web.1 | SystemStackError (stack level too deep):
15:51:24 web.1 |
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/remotipart-cd653ddc43bb/lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:46:in `call'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:30:in `render'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/remotipart-cd653ddc43bb/lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:46:in `call'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:30:in `render'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/remotipart-cd653ddc43bb/lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:46:in `call'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:30:in `render'
....
....
....
....
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/remotipart-cd653ddc43bb/lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:46:in `call'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:30:in `render'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/remotipart-cd653ddc43bb/lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:46:in `call'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/wicked_pdf-8439a045c8df/lib/wicked_pdf/pdf_helper.rb:30:in `render'
15:51:24 web.1 | actionpack (5.1.4) lib/action_controller/metal/implicit_render.rb:33:in `default_render'
15:51:24 web.1 | actionpack (5.1.4) lib/action_controller/metal/basic_implicit_render.rb:4:in `block in send_action'
15:51:24 web.1 | actionpack (5.1.4) lib/action_controller/metal/basic_implicit_render.rb:4:in `tap'
15:51:24 web.1 | actionpack (5.1.4) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
15:51:24 web.1 | actionpack (5.1.4) lib/abstract_controller/base.rb:186:in `process_action'
15:51:24 web.1 | actionpack (5.1.4) lib/action_controller/metal/rendering.rb:30:in `process_action'
15:51:24 web.1 | actionpack (5.1.4) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
15:51:24 web.1 | activesupport (5.1.4) lib/active_support/callbacks.rb:108:in `block in run_callbacks'
15:51:24 web.1 | sentry-raven (2.7.1) lib/raven/integrations/rails/controller_transaction.rb:7:in `block in included'
15:51:24 web.1 | activesupport (5.1.4) lib/active_support/callbacks.rb:117:in `instance_exec'
15:51:24 web.1 | activesupport (5.1.4) lib/active_support/callbacks.rb:117:in `block in run_callbacks'
15:51:24 web.1 | activesupport (5.1.4) lib/active_support/callbacks.rb:135:in `run_callbacks'
15:51:24 web.1 | actionpack (5.1.4) lib/abstract_controller/callbacks.rb:19:in `process_action'
15:51:24 web.1 | actionpack (5.1.4) lib/action_controller/metal/rescue.rb:20:in `process_action'
15:51:24 web.1 | actionpack (5.1.4) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
15:51:24 web.1 | activesupport (5.1.4) lib/active_support/notifications.rb:166:in `block in instrument'
15:51:24 web.1 | activesupport (5.1.4) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
15:51:24 web.1 | activesupport (5.1.4) lib/active_support/notifications.rb:166:in `instrument'
15:51:24 web.1 | actionpack (5.1.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
15:51:24 web.1 | actionpack (5.1.4) lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
15:51:24 web.1 | activerecord (5.1.4) lib/active_record/railties/controller_runtime.rb:22:in `process_action'
15:51:24 web.1 | actionpack (5.1.4) lib/abstract_controller/base.rb:124:in `process'
15:51:24 web.1 | actionview (5.1.4) lib/action_view/rendering.rb:30:in `process'
15:51:24 web.1 | actionpack (5.1.4) lib/action_controller/metal.rb:189:in `dispatch'
15:51:24 web.1 | actionpack (5.1.4) lib/action_controller/metal.rb:253:in `dispatch'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/routing/route_set.rb:31:in `serve'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/journey/router.rb:50:in `block in serve'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/journey/router.rb:33:in `each'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/journey/router.rb:33:in `serve'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/routing/route_set.rb:834:in `call'
15:51:24 web.1 | rack-pjax (1.0.0) lib/rack/pjax.rb:12:in `call'
15:51:24 web.1 | /Users/chris/.rvm/gems/ruby-2.4.1@test/bundler/gems/remotipart-cd653ddc43bb/lib/remotipart/middleware.rb:32:in `call'
15:51:24 web.1 | rack (2.0.3) lib/rack/etag.rb:25:in `call'
15:51:24 web.1 | rack (2.0.3) lib/rack/conditional_get.rb:25:in `call'
15:51:24 web.1 | rack (2.0.3) lib/rack/head.rb:12:in `call'
15:51:24 web.1 | rack (2.0.3) lib/rack/session/abstract/id.rb:232:in `context'
15:51:24 web.1 | rack (2.0.3) lib/rack/session/abstract/id.rb:226:in `call'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/middleware/cookies.rb:613:in `call'
15:51:24 web.1 | activerecord (5.1.4) lib/active_record/migration.rb:556:in `call'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
15:51:24 web.1 | activesupport (5.1.4) lib/active_support/callbacks.rb:97:in `run_callbacks'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/middleware/executor.rb:12:in `call'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
15:51:24 web.1 | web-console (3.5.1) lib/web_console/middleware.rb:135:in `call_app'
15:51:24 web.1 | web-console (3.5.1) lib/web_console/middleware.rb:20:in `block in call'
15:51:24 web.1 | web-console (3.5.1) lib/web_console/middleware.rb:18:in `catch'
15:51:24 web.1 | web-console (3.5.1) lib/web_console/middleware.rb:18:in `call'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
15:51:24 web.1 | chewy (0.10.1) lib/chewy/railtie.rb:19:in `block in call'
15:51:24 web.1 | chewy (0.10.1) lib/chewy/strategy.rb:70:in `wrap'
15:51:24 web.1 | chewy (0.10.1) lib/chewy.rb:200:in `strategy'
15:51:24 web.1 | chewy (0.10.1) lib/chewy/railtie.rb:19:in `call'
15:51:24 web.1 | railties (5.1.4) lib/rails/rack/logger.rb:36:in `call_app'
15:51:24 web.1 | railties (5.1.4) lib/rails/rack/logger.rb:24:in `block in call'
15:51:24 web.1 | activesupport (5.1.4) lib/active_support/tagged_logging.rb:69:in `block in tagged'
15:51:24 web.1 | activesupport (5.1.4) lib/active_support/tagged_logging.rb:26:in `tagged'
15:51:24 web.1 | activesupport (5.1.4) lib/active_support/tagged_logging.rb:69:in `tagged'
15:51:24 web.1 | railties (5.1.4) lib/rails/rack/logger.rb:24:in `call'
15:51:24 web.1 | sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/middleware/request_id.rb:25:in `call'
15:51:24 web.1 | rack (2.0.3) lib/rack/method_override.rb:22:in `call'
15:51:24 web.1 | rack (2.0.3) lib/rack/runtime.rb:22:in `call'
15:51:24 web.1 | activesupport (5.1.4) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/middleware/executor.rb:12:in `call'
15:51:24 web.1 | actionpack (5.1.4) lib/action_dispatch/middleware/static.rb:125:in `call'
15:51:24 web.1 | rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
15:51:24 web.1 | sentry-raven (2.7.1) lib/raven/integrations/rack.rb:51:in `call'
15:51:24 web.1 | railties (5.1.4) lib/rails/engine.rb:522:in `call'
15:51:24 web.1 | puma (3.10.0) lib/puma/configuration.rb:225:in `call'
15:51:24 web.1 | puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
15:51:24 web.1 | puma (3.10.0) lib/puma/server.rb:437:in `process_client'
15:51:24 web.1 | puma (3.10.0) lib/puma/server.rb:301:in `block in run'
15:51:24 web.1 | puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread''
@chris-gooley That fix isn't in the latest released version.
Try against master and let me know if that fixes it, and I'll release a new version to RubyGems.
gem 'wicked_pdf', github: 'mileszs/wicked_pdf'
Sorry, I should have put this in the comment, I'm already using the github version
remote: git://github.com/mileszs/wicked_pdf.git
revision: cef5e693ea9d49918c2cfc70689480d4ab2f21c0
specs:
wicked_pdf (1.1.0)
I'm also using the github release of remotipart
remote: git://github.com/mshibuya/remotipart.git
revision: cd653ddc43bb09767b8f2802d6e27b3e00ef992f
specs:
remotipart (1.3.1)
Have the same issue.
Server creashed (with exit code 3 on windows) without any logs.
For debug mode it shows stack level too deep on controller lines with render method.
Infinite loop with
D:/Ruby24-x64/lib/ruby/gems/2.4.0/bundler/gems/wicked_pdf-d96abcb6df4c/lib/wicked_pdf/pdf_helper.rb:46:in `call'
D:/Ruby24-x64/lib/ruby/gems/2.4.0/bundler/gems/wicked_pdf-d96abcb6df4c/lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
D:/Ruby24-x64/lib/ruby/gems/2.4.0/bundler/gems/wicked_pdf-d96abcb6df4c/lib/wicked_pdf/pdf_helper.rb:30:in `render'
remotipart (1.3.1) lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
The problem is somewhere in fact that both remotipart and wicked_pdf override render method.
Looks like the chain is:
render -> render_with_wicked_pdf -> render_with_remotipart -> render_without_remotipart (which is render) -> ...
(https://github.com/JangoSteve/remotipart/blob/master/lib/remotipart/render_overrides.rb#L16)
For myself I did temporarily monkeypatch to completely remove 'render' method from WickedPdf:
class WickedPdf
module PdfHelper
remove_method(:render)
end
end
I better will use explicit render_with_wicked_pdf (actually that is the way I wanted to use this gem from beginning)
PS I put this patch to config/initializers/wicked_pdf.rb, here is how it looks now:
if Gem.win_platform?
WickedPdf.config = {
exe_path: 'C:\wkhtmltopdf\bin\wkhtmltopdf.exes'
}
end
class WickedPdf
module PdfHelper
remove_method(:render)
end
end
@sintro This is a clever workaround. Thank you for sharing.
this is still an issue with wickedpdf master with rails 4.2.0 and ruby 2.2.4.
@sintro's hack no longer seems to work either.
I have the same render loop on master with rails 4.2.10 and ruby 2.3.0.
SystemStackError: stack level too deep
~/.rvm/gems/ruby-2.3.0/bundler/gems/wicked_pdf-3ed148cddb6f/lib/wicked_pdf/pdf_helper.rb:38:in `render_with_wicked_pdf'
~/.rvm/gems/ruby-2.3.0/bundler/gems/wicked_pdf-3ed148cddb6f/lib/wicked_pdf/pdf_helper.rb:30:in `render'
~/.rvm/gems/ruby-2.3.0/bundler/gems/wicked_pdf-3ed148cddb6f/lib/wicked_pdf/pdf_helper.rb:43:in `render_with_wicked_pdf'
~/.rvm/gems/ruby-2.3.0/bundler/gems/wicked_pdf-3ed148cddb6f/lib/wicked_pdf/pdf_helper.rb:30:in `render'
~/.rvm/gems/ruby-2.3.0/bundler/gems/wicked_pdf-3ed148cddb6f/lib/wicked_pdf/pdf_helper.rb:43:in `render_with_wicked_pdf'
...
And I'm trying to render a simple json response...
This issue is still occurring. Just putting the gems in my gemfile causes the SystemStackError seen above. Why would a completely unrelated and still not fixed issue be referenced in closing this?
@mattnwa You are probably experiencing a similar error with the newly released version which is currently being tracked in #810. I'm actively working on a fix, but it's not really an issue with this gem, but it's interaction with other gems that mess with render in a similar way. If you are on the current version and have new information, please add it to that issue.
Facing the same issue. Here is the log for any help on it.
SystemStackError (stack level too deep):
remotipart (1.4.2) lib/remotipart/render_overrides.rb:15:in `render_with_remotipart'
wicked_pdf (1.2.1) lib/wicked_pdf/pdf_helper.rb:46:in `call'
wicked_pdf (1.2.1) lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
wicked_pdf (1.2.1) lib/wicked_pdf/pdf_helper.rb:30:in `render'
remotipart (1.4.2) lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
wicked_pdf (1.2.1) lib/wicked_pdf/pdf_helper.rb:46:in `call'
wicked_pdf (1.2.1) lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
wicked_pdf (1.2.1) lib/wicked_pdf/pdf_helper.rb:30:in `render'
remotipart (1.4.2) lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
wicked_pdf (1.2.1) lib/wicked_pdf/pdf_helper.rb:46:in `call'
wicked_pdf (1.2.1) lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
wicked_pdf (1.2.1) lib/wicked_pdf/pdf_helper.rb:30:in `render'
remotipart (1.4.2) lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
wicked_pdf (1.2.1) lib/wicked_pdf/pdf_helper.rb:46:in `call'
wicked_pdf (1.2.1) lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
wicked_pdf (1.2.1) lib/wicked_pdf/pdf_helper.rb:30:in `render'
Thanks
Issue resolved with help of below. Thanks @sintro
class WickedPdf
module PdfHelper
remove_method(:render)
end
end
For those who are monkey patching the render method on ActionController themselves (not via a gem), I found out that in my case I could just switch to using a custom Renderer I was overriding the render method to support PLISTs, but it turns out that wasn't necessary in my case.
Most helpful comment
For myself I did temporarily monkeypatch to completely remove 'render' method from WickedPdf:
I better will use explicit
render_with_wicked_pdf(actually that is the way I wanted to use this gem from beginning)PS I put this patch to config/initializers/wicked_pdf.rb, here is how it looks now: