Wicked_pdf: SystemStackError when app also uses the okcomputer gem

Created on 18 Apr 2019  路  3Comments  路  Source: mileszs/wicked_pdf

Issue description

If your Rails (in my case Rails 4.2.11) app also uses the okcomputer gem, then you'll get a SystemStackError when trying to visit the /okcomputer url. Works fine with version 1.1.0 of wicked_pdf.

Expected or desired behavior

Should be able to use okcomputer gem as well as wicked_pdf

System specifications

wicked_pdf gem version (output of cat Gemfile.lock | grep wicked_pdf):
Problem occurs with wicked_pdf 1.2.0, 1.2.1 and 1.2.2

wkhtmltopdf version (output of wkhtmltopdf --version):

whtmltopdf provider gem and version if one is used:

platform/distribution and version (e.g. Windows 10 / Ubuntu 16.04 / Heroku cedar):

Most helpful comment

Yes, I think that's related. Both gems mess with render.

It's planned for WickedPdf 2.0 to define a renderer with the Rails renderers.add method or a base wicked_pdf(options) method you can call from the controller, instead of messing with render itself.

I'd like it to first be opt-in to deprecate the override and bridge compatibility to a 2.0 release, where we drop the alias/prepend code altogether.

I've been pretty busy lately though, so I'd love it if you or someone else reading this could help me out.

All 3 comments

@BlakeWard I wonder if this is related to https://github.com/mileszs/wicked_pdf/issues/823 I'm also having this issue where I'm trying to override ActionController::Base's render method by using Module#prepend but because of the aliasing done by WickedPDF for render, it's hitting a stack overflow error.

Yes, I think that's related. Both gems mess with render.

It's planned for WickedPdf 2.0 to define a renderer with the Rails renderers.add method or a base wicked_pdf(options) method you can call from the controller, instead of messing with render itself.

I'd like it to first be opt-in to deprecate the override and bridge compatibility to a 2.0 release, where we drop the alias/prepend code altogether.

I've been pretty busy lately though, so I'd love it if you or someone else reading this could help me out.

If it helps, here's the hack I'm currently using to get around this problem:

  def render_without_wicked_pdf(*options, &block)
    m = method(:render)
    until m.nil? || m.owner == ActionController::Rendering
      m = m.super_method
    end
    m&.(*options, &block)
  end
Was this page helpful?
0 / 5 - 0 ratings