Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WickedPDF is killing my application. SystemStackError (stack level too deep): #823

Open
krtschmr opened this issue Apr 5, 2019 · 9 comments

Comments

@krtschmr
Copy link

krtschmr commented Apr 5, 2019

Application is working fine.

added wicked_pdf to gemfile

now nothing is working andymore and i always receive the following message

SystemStackError (stack level too deep):
  actionpack (4.2.3) lib/action_dispatch/middleware/reloader.rb:79

rails 4.2.3 with ruby 2.1.0

adding initializer or mimetype won't fix it

@unixmonkey
Copy link
Collaborator

What version of WickedPDF?
See #810
If you are on 1.2.2 (current version), please post more of your stack trace.
You can always revert to version 1.1.0 for now.

@brunovelasco
Copy link

brunovelasco commented Apr 8, 2019

1.2.2 didn't work for me.

My case scenario is that another gem redefines render method and super'it

(https://github.com/spree-contrib/spree_multi_currency/blob/master/app/controllers/spree/admin/general_settings_controller_decorator.rb)

      def render(*args)
        @preferences_currency |= [:allow_currency_change, :show_currency_selector, :supported_currencies]
        super
      end

When it attempts to render these controller's views, I have the stack too deep error.

[EDIT]
Using rails 5.2.2

@unixmonkey
Copy link
Collaborator

@brunovelasco Thank you for reporting this.

@krtschmr Did you try updating yet, or did you ever figure out which dependency is getting in a loop with WickedPdf?

@opensourceame
Copy link

I had this with wicked_pdf 1.2.1 on rails 4.2.10 and ruby 2.4.4. Upgrading to wicked_pdf 1.2.2 fixed it. Just posting this in case the combination of components helps someone else.

@rubydev
Copy link

rubydev commented Apr 17, 2019

I have same problem.

rails 5.2.3
wicked_pdf 1.2.2

and in controller I have:

    def render(*args)
      options = args.extract_options!
      options[:template] = "/admin/hotel_reservations/hotelbeds/#{params[:action]}"
      super(*(args << options))
    end

and this error:

SystemStackError (stack level too deep):
  
app/controllers/admin/hotelbeds_reservations_controller.rb:90:in `render'
app/controllers/admin/hotelbeds_reservations_controller.rb:22:in `new'

with wicked_pdf version 1.2.0 and 1.2.1:

SystemStackError (stack level too deep):
  
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'
remotipart (1.4.2) lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'

Only with wicked_pdf 1.1.0 it works.

@krtschmr
Copy link
Author

@rubydev

offtopic:

throw your render method away.
https://guides.rubyonrails.org/action_view_overview.html#prepend-view-path

prepend_view_path "/admin/hotel_reservations/hotelbeds"

problem solved

@rubydev
Copy link

rubydev commented Apr 18, 2019

@krtschmr Thanks, but it not help, because views are in paths:

app/views/admin/hotel_reservations/hotelbeds/
app/views/admin/hotel_reservations/cangooroo/

and controllers are:

hotelbeds_reservations and cangooroo_reservations

and

prepend_view_path can prepend path, but last folder should be same like controller name. It is explained in this issue.

So I changed my code to

    def render_cangooroo_template
      render layout: false, template: "/admin/hotel_reservations/cangooroo/#{params[:action]}"
    end

And it is fixed for me.

@krtschmr
Copy link
Author

it's still bad code. very bad actually.

i don't know about your routes, but i assume you have a HotelbedsReservationsController and a CangoorooReservationscontroller

both should be inheriting from a Reservationscontroller so it should be HotelbedsController < ReservationsController and CangorooController < ReservationsController (or advanced Reservations::CangoroController).

class ReservationsController < ApplicationController
  layout false
  before_action :set_view_path

  private
   def set_view_path
     prepend_view_path "app/views/admin/#{controller_name}"
  end    
end

but you don't even need to deal with this stuff if you have the correct namespacing and naming.

having one controller serving 2 templates is most of the time very bad approach. instead making it 2 controllers. those are different things anyways ;)

@rubydev
Copy link

rubydev commented Apr 18, 2019

@krtschmr You are right, I will change namespacing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants