rposborne/wkhtmltopdf-heroku

What does this buy us exactly?

Closed this issue · 45 comments

Would love an explanation in the readme on what this gem does exactly and why it's needed.

I'm using the following two gems on Heroku:

gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'

Also, using paperclip/S3 to attach the files to a model.

It works sometimes, sometimes I get this error (seems random on when it works):

Error: Failed to execute:
2016-03-17T19:25:16.368818+00:00 app[web.1]: ["/app/vendor/bundle/ruby/2.0.0/bin/wkhtmltopdf", "-q", "file:////tmp/wicked_pdf20160317-15-h75sns.html", "/tmp/wicked_pdf_generated_file20160317-15-pmd4c9.pdf"]
2016-03-17T19:25:16.368819+00:00 app[web.1]: Error: Interrupted system call - /app/vendor/bundle/ruby/2.0.0/bin/wkhtmltopdf
2016-03-17T19:25:16.370493+00:00 app[web.1]: Completed 400 Bad Request in 6578ms (Views: 0.7ms | ActiveRecord: 252.3ms)

Sorry, I know this isn't a very detailed error.
Do you know if this gem will solve whatever the problem here is? Does the error have something to do with writing to the filesystem on Heroku?

Do I need to replace the 'wkhtmltopdf-binary' gem with this one?

Thanks much.

Hello,

wkhtmltopdf-heroku gem provides the latest binary built for Ubuntu 14.04 LTS (which is used by heroku)

the binary gem you are using may provide an outdated version of wkhtmltopdf . that gem was meant for development and testing since it contains different binaries for different OS.

I'd recommend switching to this gem and see if the error persists. Also for development please try 'wkhtmltopdf-binary-edge' gem since the original one is no longer maintained.

since your issue happens randomly - I'd suggest take a look into your html file. does it happen for all htmls? or only specific ones? could you try to replicate this issue by generating PDFs for the same file repetitively? (in heroku console)

I've been using this gem in production for years - generated ten thousands of PDFs without any major issues. one thing to note is that I try to avoid using external resources in the HTML. I use helpers to convert any external files(css, js, images, fonts) to base64 strings and embed them into the html directly. Also please try to avoid remote resources ( loading files that are not on your server) - which may be causing wkhtmltopdf to timeout randomly.

-P

Sent from my iPhone

On Mar 17, 2016, at 16:30, Micah Lisonbee notifications@github.com wrote:

Would love an explanation in the readme on what this gem does exactly and why it's needed.

I'm using the following two gems on Heroku:

gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
Also, using paperclip/S3 to attach the files to a model.

It works sometimes, sometimes I get this error (seems random on when it works):

Error: Failed to execute:
2016-03-17T19:25:16.368818+00:00 app[web.1]: ["/app/vendor/bundle/ruby/2.0.0/bin/wkhtmltopdf", "-q", "file:////tmp/wicked_pdf20160317-15-h75sns.html", "/tmp/wicked_pdf_generated_file20160317-15-pmd4c9.pdf"]
2016-03-17T19:25:16.368819+00:00 app[web.1]: Error: Interrupted system call - /app/vendor/bundle/ruby/2.0.0/bin/wkhtmltopdf
2016-03-17T19:25:16.370493+00:00 app[web.1]: Completed 400 Bad Request in 6578ms (Views: 0.7ms | ActiveRecord: 252.3ms)
Sorry, I know this isn't a very detailed error.
Do you know if this gem will solve whatever the problem here is? Does the error have something to do with writing to the filesystem on Heroku?

Thanks much.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub

So my gemfile would look something like this?

gem 'wicked_pdf'
gem 'wkhtmltopdf-binary-edge', group: [:development]
gem 'wkhtmltopdf-heroku', group: [:production, :staging]

It happens randomly when generating the exact same html file with the exact same variables. I will run the same command over and over, sometimes it errors, sometimes it doesn't...

yes.

well could you try it again with the latest version and see if the problem persists?
how big is the HTML file? could you share it if possible?

I briefly tried with the gemfile as shown above and got this error on Heroku (worked fine locally):

Error: PDF could not be generated!
2016-03-17T20:50:18.349888+00:00 app[web.1]:  Command Error: /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:355:in `block in replace_bin_path': can't find executable wkhtmltopdf (Gem::Exception)
2016-03-17T20:50:18.349889+00:00 app[web.1]:    from /app/vendor/bundle/bin/wkhtmltopdf:16:in `<main>'
2016-03-17T20:50:18.349890+00:00 app[web.1]: 
2016-03-17T20:50:18.350906+00:00 app[web.1]: Completed 400 Bad Request in 1447ms (Views: 0.5ms | ActiveRecord: 181.7ms)

try it again with the latest version.

Can you detail the gem configuration you recommend to test this?

The HTML files are pretty much placeholders for now, super simple. Here is a link to a generated PDF: https://s3.amazonaws.com/licenses-stg.foundermusic.com/5vDRN0dJmkZHsckBeTgleQ/8i2Bo0j1tr7XNjJZo5x9xQ-license.pdf

Here's the erb template:

<p>
    License details: <%= license.user.first_name %>  <%= license.user.last_name %> <br>
    Project Name: <%= license.project_name %> <br>
    Price: $<%= license.charge_amount %>

</p>

Here's the method that generates the PDF:


def generate_license_pdf

        @license = self

        begin
            view = ActionView::Base.new(ActionController::Base.view_paths, {})
            # Include helpers and routes
            view.extend(ApplicationHelper)
            view.extend(Rails.application.routes.url_helpers)

            pdf = WickedPdf.new.pdf_from_string(
             view.render(
               :pdf => "license",
               :template => 'api/v1/licenses/pdf_license_template.html.erb',
               :locals => { :license => self }
             )
            )

            pdf_name = "#{self.apikey}-license.pdf" 
            # save PDF to disk
            pdf_path = Rails.root.join('tmp', pdf_name)
            File.open(pdf_path, 'wb') do |file|
                file << pdf
            end

            file = File.open pdf_path
            self.update_attribute(:pdf_license, file)

            # The license has now been saved to S3 using Paperclip; we don't need to store it locally
            File.delete(pdf_path) if File.exist?(pdf_path)

            return true
        rescue => e
            Rails.logger.info e
            return false
        end

    end

what's your wicked_pdf configuration?
removing exe_path from your configs should solve this problem.

I have no customizations in the config:

# WickedPDF Global Configuration
#
# Use this to set up shared configuration options for your entire application.
# Any of the configuration options shown here can also be applied to single
# models by passing arguments to the `render :pdf` call.
#
# To learn more, check out the README:
#
# https://github.com/mileszs/wicked_pdf/blob/master/README.md

WickedPdf.config = {
  # Path to the wkhtmltopdf executable: This usually isn't needed if using
  # one of the wkhtmltopdf-binary family of gems.
  # exe_path: '/usr/local/bin/wkhtmltopdf',
  #   or
  # exe_path: Gem.bin_path('wkhtmltopdf-binary', 'wkhtmltopdf')

  # Layout file to be used for all PDFs
  # (but can be overridden in `render :pdf` calls)
  # layout: 'pdf.html',
}

could you login to heroku rails console, and output the values in WickedPdf.config ?
the heroku gem should config the path for you

I use wise_pdf instead of wicked_pdf but they should be the same (just different wkthmltopdf wrappers really)

some of my code for pdf generation:

    pdf_file = Tempfile.new(["report", ".pdf"])
    pdf_file.write((ApplicationController.new.tap do |controller|
      controller.instance_variable_set(:@report, @report)
      controller.params = { id: @report.id }
    end).render_to_string_with_wisepdf(pdf: "report.pdf",
                                       page_size: @report.page_size,
                                       template: @report.pdf_template_path,
                                       layout: @report.pdf_layout_path).force_encoding('utf-8'))

this generates a Tempfile which I will need later on to group/zip/encrypt/upload

irb(main):001:0> WickedPdf.config
=> {}

Maybe I'll try and switch to wise_pdf...

well if wkhtmltopdf-heroku is installed correctly you should see an exe_path in the config.

could you verify what's the version of your wkhtmltopdf_heroku?

I usually specify the version in my gem file

group :production do
  gem 'wkhtmltopdf-heroku', '~> 2.12.3.0'
end

Oh sorry, I forgot to re-add wkhtmltopdf_heroku to the gemfile. Here is the output with the wkhtmltopdf_heroku gem:

Actually, same output after I added it. Here's my gemfile:

gem 'wicked_pdf'
gem 'wkhtmltopdf-binary-edge', group: [:development]
gem 'wkhtmltopdf-heroku', group: [:production, :staging]

Heroku deploy logged: Installing wkhtmltopdf-heroku 2.12.3.0

so...it's working now? 👯

No, same error as before regarding the executable.


Error: PDF could not be generated!
2016-03-17T21:22:26.950518+00:00 app[web.1]:  Command Error: /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:355:in `block in replace_bin_path': can't find executable wkhtmltopdf (Gem::Exception)
2016-03-17T21:22:26.950519+00:00 app[web.1]:    from /app/vendor/bundle/bin/wkhtmltopdf:16:in `<main>'
2016-03-17T21:22:26.950520+00:00 app[web.1]: ):
2016-03-17T21:22:26.950520+00:00 app[web.1]:   app/models/license.rb:44:in `generate_license_pdf'

odd.. i wonder if everything was cleaned up properly when you removed the binary gem.
this gem doesn't create executables under app/vendor/bundle/bin/wkhtmltopdf

could you search wkhtmltopdf in your codebase and see what you find?

also if you puts ls /app/vendor/bundle/bin/ on heroku console
you should see a wkhtmltopdf-linux-amd64 file - which is provided by this gem.

you can also try to config your wicked_pdf exe path manually

WickedPdf.config = {
  exe_path: Gem.bin_path('wkhtmltopdf-heroku')
}

but your errors seems to be caused by a configuration somewhere trying to find wkthmltopdf in a different path.

Searching reveals some entries in gemfile and gemfile.lock. Want me to paste those entire files?

wkhtmltopdf-linux-amd64 does exist in that path on Heroku.

nah...what about environment variables? do you have anything related to wkhtmltopdf?

Nothing else related to wkhtmltopdf.

I just tried to manually set exe path per your example and push to heroku and got this error when deploying:

Gem::Exception: can't find executable wkhtmltopdf

FYI, I'm running:

Rails 4.1.8
Puma web server

I haven't been following up with wicked_pdf's updates.
just searched their code base, it seems they are trying to set a default exe_path if nothing is set in the initializer.

let me create an empty app with wicked_pdf and see if i can replicate this.

will get back to you in a few hours.

I appreciate all your help, looking forward to hearing back.

hey @micahlisonbee
I created a sample app here https://wickedpdf-test.herokuapp.com/?format=pdf

I think this gem is not configuring wicked_pdf correctly. I'm trying to fix it.

to get the app to work I had to manually config wicked_pdf in app/initializers/wicked_pdf.rb

WickedPdf.config = {
  exe_path: Rails.env.production? ? Gem.bin_path('wkhtmltopdf-heroku') : nil
}

could you try that?

Actually - I think I know what's causing the issue here. (feeling silly right now)
so, when app loads

  1. our gem configures the exe_path for WickedPdf
  2. in the wicked_pdf initializer...it overwrites the config hash with an assignment: WickedPdf.config = { ... that's why the exe_path is gone after the app is loaded :(

I removed the wicked_pdf.rb completely and it worked.

So if you need additional settings in the initializer, try:

WickedPdf.config ||= {}
WickedPdf.config.merge!({
   # your settings here. 
})

I removed wicked_pdf.rb completely, which allowed wkhtmltopdf-heroku to work on Heroku. However, every 4-5th time generating the same pdf I still get this error:

RuntimeError (Error: Failed to execute:
2016-03-18T18:16:00.177738+00:00 app[web.1]: ["/app/vendor/bundle/ruby/2.0.0/gems/wkhtmltopdf-heroku-2.12.3.0/bin/wkhtmltopdf-linux-amd64", "-q", "file:////tmp/wicked_pdf20160318-11-nmnir9.html", "/tmp/wicked_pdf_generated_file20160318-11-63dlvb.pdf"]
2016-03-18T18:16:00.177739+00:00 app[web.1]: Error: Interrupted system call - /app/vendor/bundle/ruby/2.0.0/gems/wkhtmltopdf-heroku-2.12.3.0/bin/wkhtmltopdf-linux-amd64):
2016-03-18T18:16:00.177740+00:00 app[web.1]:   app/models/license.rb:44:in `generate_license_pdf'
2016-03-18T18:16:00.177740+00:00 app[web.1]:   app/controllers/api/v1/licenses_controller.rb:51:in `create'

I wonder if it has something to do with your implementation.
could you try my Tempfile approach? You don't need to delete files manually, and in your code you are opening the same file multiple times.
it seems the path scheme file:////tmp/w... in the command is incorrect.

    pdf_file = Tempfile.new(["#{self.apikey}-license" , ".pdf"])
    pdf_file.write WickedPdf.new.pdf_from_string(...)

    self.update_attribute(:pdf_license, pdf_file)
ensure
    pdf_file.close
end

When I use the Tempfile method I get encoding issues:

Encoding::UndefinedConversionError ("\xFE" from ASCII-8BIT to UTF-8):

I can't figure out how to force_encoding.

Maybe I should switch to wise_pdf at this point and use your example...

ah, yea, you just need to call force_encoding on the output string.

WickedPdf.new.pdf_from_string(...).force_encoding('utf-8')

wisepdf is no longer maintained (as it seems), if you could get wicked_pdf to work I think that's a safer option. :)

Can you post your full example from your demo site (using wicked_pdf and Tempfile)? I'm having issues now, the PDF generated is empty and the name has a weird string concatenated on the end...

sure...the source code is here: https://github.com/pallymore/wickedpdf-test

Also I added a download feature - which generates a tempfile and send it to the client - this should mimic what you are trying to do.

https://wickedpdf-test.herokuapp.com/download

I noticed there is an issue with my previous comment. pdf_from_string generates a file instead of a string. so it cannot be used with Tempfile#write or force_encoding
so maybe try this:

             pdf_file.write(view.render_to_string(
               :pdf => "license",
               :template => 'api/v1/licenses/pdf_license_template.html.erb',
               :locals => { :license => self }
             ).force_encoding('utf-8'))

regarding the filename, yes Tempfile automatically generates some random string in the filename to avoid name collisions. You can change the filename when you save it to your model - the method depends on what gem you are using to upload the file to s3.

I use paperclip - to change filename, use this

in your method:

      self.file = pdf_file
      self.file.instance_write(:file_name, "yourfilenamehere.pdf")
      self.save!

I'm doing this in the license.rb model so I don't think I have access to render_to_string.

NoMethodError (undefined method 'render_to_string' for #<ActionView::Base:0x007fb0829411e8>):

right..my bad, render_to_string is a controller method, not View.

use controller instance instead

  ApplicationController.new.render_to_string(
   # your params. 
  ).force_encoding('utf-8')

personally I prefer this over initializing a view and extend the helpers.

You could also replace ApplicationController with the actual controller you use (to render the html version of the page)

e.g.

LicensesController.new.render_to_string

if there are required parameters, you can set it here as well

    LicensesController.new.tap do |controller|
      controller.params = { id: your_id }
    end.render_to_string

I discovered another way to make this work, without using any temp files at all. This works locally, going to test on Heroku now... What do you think of this?

pdf_html = WickedPdf.new.pdf_from_string(
             view.render(
               :pdf => "license",
               :template => 'api/v1/licenses/pdf_license_template.html.erb',
               :locals => { :license => self }
             )
            )

self.pdf_license = StringIO.new( pdf_html )
self.pdf_license.instance_write(:file_name, "#{self.apikey}-license.pdf")
self.save

well it may work but it may not be very efficient.
when you do view.render with pdf parameter, it's likely that WickedPdf (as a middleware) will render this with wkhtmltopdf, then when you call pdf_from_string it may call wkhtmltopdf again.

when you are testing it locally, you should be able to see how many times wkhtmltopdf is invoked in your console.

also the last line should be self.save ? assuming self is an instance of your model.

The pdf_html = code is actually the same as what was writing at pdf_file.write(... before. The only thing I changed was instead of writing it to a file, I render as a new string StringIO.new( pdf_html ) then set the name manually as you showed (using paperclip).

Just tested this 10 times in a row on Heroku w/out any errors. I'll use it for now and keep an eye on it. Thank you big time. You have gone well outside the scope of this project to help me with my issue.

no problem :) let me know if you have more questions about wkthmltopdf

Thanks!

Unfortunately, the same errors started popping up again today. I have been working on the formatting of the PDF's and am now including pre-rendered html for footer/header.

2016-03-24T21:49:31.000117+00:00 app[web.1]: Error: Failed to execute:
2016-03-24T21:49:31.000126+00:00 app[web.1]: ["/app/vendor/bundle/ruby/2.0.0/gems/wkhtmltopdf-heroku-2.12.3.0/bin/wkhtmltopdf-linux-amd64", "-q", "--page-size", "Letter", "--margin-top", "60", "--margin-bottom", "30", "--margin-left", "20", "--margin-right", "20", "--header-spacing", "20", "--header-html", "file:////tmp/wicked_header_pdf20160324-15-19qnkcf.html", "--footer-spacing", "15", "--footer-html", "file:////tmp/wicked_footer_pdf20160324-15-wipwx8.html", "file:////tmp/wicked_pdf20160324-15-15uiz08.html", "/tmp/wicked_pdf_generated_file20160324-15-zdu5kb.pdf"]
2016-03-24T21:49:31.000156+00:00 app[web.1]: Error: Interrupted system call - /app/vendor/bundle/ruby/2.0.0/gems/wkhtmltopdf-heroku-2.12.3.0/bin/wkhtmltopdf-linux-amd64
2016-03-24T21:49:31.001365+00:00 app[web.1]: Completed 400 Bad Request in 885ms (Views: 0.6ms | ActiveRecord: 185.3ms)

I'm on Heroku (staging)
My gemfile:

gem 'wicked_pdf'
gem 'wkhtmltopdf-binary-edge', group: [:development]
gem 'wkhtmltopdf-heroku', group: [:production_heroku, :staging]

Here's the full stack trace:

Error: Failed to execute:
2016-03-24T22:13:02.101673+00:00 app[web.1]: ["/app/vendor/bundle/ruby/2.0.0/gems/wkhtmltopdf-heroku-2.12.3.0/bin/wkhtmltopdf-linux-amd64", "-q", "--page-size", "Letter", "--margin-top", "60", "--margin-bottom", "30", "--margin-left", "20", "--margin-right", "20", "--header-spacing", "20", "--header-html", "file:////tmp/wicked_header_pdf20160324-21-1ewah39.html", "--footer-spacing", "15", "--footer-html", "file:////tmp/wicked_footer_pdf20160324-21-n5caob.html", "file:////tmp/wicked_pdf20160324-21-16b379g.html", "/tmp/wicked_pdf_generated_file20160324-21-idyplj.pdf"]
2016-03-24T22:13:02.101675+00:00 app[web.1]: Error: Interrupted system call - /app/vendor/bundle/ruby/2.0.0/gems/wkhtmltopdf-heroku-2.12.3.0/bin/wkhtmltopdf-linux-amd64
2016-03-24T22:13:02.102372+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/wicked_pdf-1.0.3/lib/wicked_pdf.rb:62:in `rescue in pdf_from_string'
2016-03-24T22:13:02.102380+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/wicked_pdf-1.0.3/lib/wicked_pdf.rb:65:in `pdf_from_string'
2016-03-24T22:13:02.102381+00:00 app[web.1]: /app/app/models/license.rb:79:in `generate_pdf'
2016-03-24T22:13:02.102382+00:00 app[web.1]: /app/app/controllers/api/v1/licenses_controller.rb:45:in `create'
2016-03-24T22:13:02.102383+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
2016-03-24T22:13:02.102383+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/abstract_controller/base.rb:189:in `process_action'
2016-03-24T22:13:02.102384+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/rendering.rb:10:in `process_action'
2016-03-24T22:13:02.102385+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
2016-03-24T22:13:02.102385+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:113:in `call'
2016-03-24T22:13:02.102386+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:113:in `call'
2016-03-24T22:13:02.102387+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
2016-03-24T22:13:02.102389+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:229:in `call'
2016-03-24T22:13:02.102390+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:229:in `block in halting'
2016-03-24T22:13:02.102390+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:229:in `call'
2016-03-24T22:13:02.102396+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:229:in `block in halting'
2016-03-24T22:13:02.102397+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
2016-03-24T22:13:02.102397+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
2016-03-24T22:13:02.102398+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
2016-03-24T22:13:02.102399+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
2016-03-24T22:13:02.102399+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:229:in `call'
2016-03-24T22:13:02.102400+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:229:in `block in halting'
2016-03-24T22:13:02.102400+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
2016-03-24T22:13:02.102401+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
2016-03-24T22:13:02.102401+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:86:in `call'
2016-03-24T22:13:02.102402+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:86:in `run_callbacks'
2016-03-24T22:13:02.102403+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/abstract_controller/callbacks.rb:19:in `process_action'
2016-03-24T22:13:02.102403+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/rescue.rb:29:in `process_action'
2016-03-24T22:13:02.102404+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
2016-03-24T22:13:02.102405+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/notifications.rb:159:in `block in instrument'
2016-03-24T22:13:02.102405+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
2016-03-24T22:13:02.102406+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/notifications.rb:159:in `instrument'
2016-03-24T22:13:02.102406+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
2016-03-24T22:13:02.102407+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
2016-03-24T22:13:02.102408+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
2016-03-24T22:13:02.102408+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/abstract_controller/base.rb:136:in `process'
2016-03-24T22:13:02.102409+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.8/lib/action_view/rendering.rb:30:in `process'
2016-03-24T22:13:02.102409+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal.rb:196:in `dispatch'
2016-03-24T22:13:02.102410+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
2016-03-24T22:13:02.102450+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal.rb:232:in `block in action'
2016-03-24T22:13:02.102452+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:82:in `call'
2016-03-24T22:13:02.102452+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
2016-03-24T22:13:02.102453+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:50:in `call'
2016-03-24T22:13:02.102454+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/journey/router.rb:73:in `block in call'
2016-03-24T22:13:02.102454+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/journey/router.rb:59:in `each'
2016-03-24T22:13:02.102455+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/journey/router.rb:59:in `call'
2016-03-24T22:13:02.102456+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:678:in `call'
2016-03-24T22:13:02.102456+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102457+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
2016-03-24T22:13:02.102458+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102458+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/rack/browser_monitoring.rb:32:in `traced_call'
2016-03-24T22:13:02.102459+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102460+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/deflater.rb:25:in `call'
2016-03-24T22:13:02.102461+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102461+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/etag.rb:23:in `call'
2016-03-24T22:13:02.102462+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102463+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/conditionalget.rb:35:in `call'
2016-03-24T22:13:02.102463+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102464+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/head.rb:11:in `call'
2016-03-24T22:13:02.102465+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102465+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
2016-03-24T22:13:02.102466+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102467+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/flash.rb:254:in `call'
2016-03-24T22:13:02.102467+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102468+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/session/abstract/id.rb:225:in `context'
2016-03-24T22:13:02.102469+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/session/abstract/id.rb:220:in `call'
2016-03-24T22:13:02.102469+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102470+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/cookies.rb:560:in `call'
2016-03-24T22:13:02.102470+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102471+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/query_cache.rb:36:in `call'
2016-03-24T22:13:02.102472+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102472+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
2016-03-24T22:13:02.102473+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102473+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
2016-03-24T22:13:02.102474+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:82:in `run_callbacks'
2016-03-24T22:13:02.102505+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2016-03-24T22:13:02.102507+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102507+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
2016-03-24T22:13:02.102508+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102509+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
2016-03-24T22:13:02.102509+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102510+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2016-03-24T22:13:02.102510+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102511+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/rack/logger.rb:38:in `call_app'
2016-03-24T22:13:02.102512+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/rack/logger.rb:20:in `block in call'
2016-03-24T22:13:02.102512+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/tagged_logging.rb:68:in `block in tagged'
2016-03-24T22:13:02.102513+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/tagged_logging.rb:26:in `tagged'
2016-03-24T22:13:02.102513+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/tagged_logging.rb:68:in `tagged'
2016-03-24T22:13:02.102514+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/rack/logger.rb:20:in `call'
2016-03-24T22:13:02.102514+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102515+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2016-03-24T22:13:02.102516+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102516+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/methodoverride.rb:21:in `call'
2016-03-24T22:13:02.102517+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102517+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/runtime.rb:17:in `call'
2016-03-24T22:13:02.102518+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102519+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
2016-03-24T22:13:02.102519+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102520+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/static.rb:84:in `call'
2016-03-24T22:13:02.102522+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102523+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/sendfile.rb:112:in `call'
2016-03-24T22:13:02.102529+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102529+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-cors-0.4.0/lib/rack/cors.rb:80:in `call'
2016-03-24T22:13:02.102530+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102530+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:514:in `call'
2016-03-24T22:13:02.102531+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/application.rb:144:in `call'
2016-03-24T22:13:02.102532+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.14.2.312/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
2016-03-24T22:13:02.102532+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/puma-3.0.2/lib/puma/configuration.rb:221:in `call'
2016-03-24T22:13:02.102533+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/puma-3.0.2/lib/puma/server.rb:561:in `handle_request'
2016-03-24T22:13:02.102533+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/puma-3.0.2/lib/puma/server.rb:406:in `process_client'
2016-03-24T22:13:02.102534+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/puma-3.0.2/lib/puma/server.rb:271:in `block in run'
2016-03-24T22:13:02.102534+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/puma-3.0.2/lib/puma/thread_pool.rb:111:in `call'
2016-03-24T22:13:02.102538+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/puma-3.0.2/lib/puma/thread_pool.rb:111:in `block in spawn_thread'
2016-03-24T22:13:02.104422+00:00 app[web.1]: Completed 400 Bad Request in 2192ms (Views: 0.9ms | ActiveRecord: 168.5ms)

hmm do you use spring ? what's its version?

In development spring (1.2.0)

Gemfile:

gem 'spring', group: :development

the current version is 1.6.x ... i saw someone is having a similar problem in the wicked_pdf issues: mileszs/wicked_pdf#361

Also a few other people mentioned similar errors.
Although I believe it's unlikely the fault of wicked_pdf - but could you try wisepdf ? :)

I created an issue over at wicked_pdf.
I'll look into the the Spring relation.

I will try wisepdf if I can't figure it out... Thanks!