Git Product home page Git Product logo

Comments (6)

sashazykov avatar sashazykov commented on September 27, 2024

Capybara::Poltergeist::JavascriptError exception type

from webshot.

vitalie avatar vitalie commented on September 27, 2024

Strange, which URL raised the JS error? By default JS errors are ignored, see:
https://github.com/vitalie/webshot/blob/master/lib/webshot.rb#L40

from webshot.

sashazykov avatar sashazykov commented on September 27, 2024

http://www.uleshi.ru/ for example:

Capybara::Poltergeist::JavascriptError: One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details). ReferenceError: Can't find variable: fulltime ReferenceError: Can't find variable: fulltime at http://www.uleshi.ru/:147 SyntaxError: Parse error SyntaxError: Parse error

or this one http://gadishot.blogspot.de/

Capybara::Poltergeist::JavascriptError: One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details). TypeError: 'undefined' is not an object (evaluating 'entry.title') TypeError: 'undefined' is not an object (evaluating 'entry.title') at http://gadishot.blogspot.de/:566 in showrecentposts4 at http://gadishot.blogspot.de/feeds/posts/default/-/Artikel?max-results=1&orderby=published&alt=json-in-script&callback=showrecentposts4:2 TypeError: 'undefined' is not an object (evaluating 'entry.title') TypeError: 'undefined' is not an object (evaluating 'entry.title') at http://gadishot.blogspot.de/:349 in showrecentposts2 at http://gadishot.blogspot.de/feeds/posts/default/-/infotainment?max-results=1&orderby=published&alt=json-in-script&callback=showrecentposts2:2 TypeError: 'undefined' is not an object (evaluating 'entry.title') TypeError: 'undefined' is not an object (evaluating 'entry.title') at http://gadishot.blogspot.de/:1290 in showrecentposts8 at http://gadishot.blogspot.de/feeds/posts/default/-/video?max-results=4&orderby=published&alt=json-in-script&callback=showrecentposts8:2 TypeError: 'undefined' is not an object (evaluating 'entry.title') TypeError: 'undefined' is not an object (evaluating 'entry.title') at http://gadishot.blogspot.de/:786 in showrecentposts5 at http://gadishot.blogspot.de/feeds/posts/default/-/Life%20Style?max-results=2&orderby=published&alt=json-in-script&callback=showrecentposts5:2

from webshot.

vitalie avatar vitalie commented on September 27, 2024

I can't reproduce your problem:

# File: t.rb
require 'webshot'
ws = Webshot::Screenshot.instance
ws.capture ARGV.first, "output.png"
$ ruby -v
ruby 1.9.3p545 (2014-02-24 revision 45159) [x86_64-linux]

$ phantomjs --version
1.9.7

$ ruby t.rb http://www.uleshi.ru/
Unsafe JavaScript attempt to access frame with URL http://www.uleshi.ru/ from frame with URL http://www.ustream.tv/embed/10985073. Domains, protocols and ports must match.

$ ruby t.rb http://gadishot.blogspot.de/
Invalid App Id: Must be a number or numeric string representing the application id.
FB.getLoginStatus() called before calling FB.init().
[...]

from webshot.

sashazykov avatar sashazykov commented on September 27, 2024
$ rails c
Loading development environment (Rails 3.2.18)
2.0.0-p481 :001 > Webshot::Screenshot.instance.capture('http://www.uleshi.ru/', "/tmp/thumb.png", width: 1024, height: 768)
2014-05-30 23:18:09.096 phantomjs[5538:507] CoreText performance note: Client called CTFontCreateWithName() using name "Arial" and got font with PostScript name "ArialMT". For best performance, only use PostScript names when calling this API.
2014-05-30 23:18:09.096 phantomjs[5538:507] CoreText performance note: Set a breakpoint on CTFontLogSuboptimalRequest to debug.
2014-05-30 23:18:09.904 phantomjs[5538:507] CoreText performance note: Client called CTFontCreateWithName() using name "Times New Roman" and got font with PostScript name "TimesNewRomanPSMT". For best performance, only use PostScript names when calling this API.
PhantomJS has crashed. Please read the crash reporting guide at https://github.com/ariya/phantomjs/wiki/Crash-Reporting and file a bug report at https://github.com/ariya/phantomjs/issues/new with the crash dump file attached: /tmp/6ECD4D02-C041-460E-BC15-7A504780E742.dmp
Webshot::WebshotError: Capybara error: "PhantomJS client died while processing {\"name\":\"visit\",\"args\":[\"http://www.uleshi.ru/\"]}"
    from /Users/sashazykov/.rvm/gems/ruby-2.0.0-p481/gems/webshot-0.0.5/lib/webshot/screenshot.rb:81:in `rescue in capture'
    from /Users/sashazykov/.rvm/gems/ruby-2.0.0-p481/gems/webshot-0.0.5/lib/webshot/screenshot.rb:30:in `capture'
    from (irb):1
    from /Users/sashazykov/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.18/lib/rails/commands/console.rb:47:in `start'
    from /Users/sashazykov/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.18/lib/rails/commands/console.rb:8:in `start'
    from /Users/sashazykov/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.18/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

ruby 2.0.0-p481 / 2.0.0-p451
phantomjs 1.9.2 / 1.9.7
webshot 0.0.5
poltergeist 1.5.0
capybara 2.1.0

from webshot.

vitalie avatar vitalie commented on September 27, 2024

I've repeated the test without any luck:

  • ruby 2.0.0p451
  • phantomjs 1.9.7
  • webshot 0.0.5
  • capybara 2.2.1
  • poltergeist 1.5.0

I wouldn't recommend running it directly from Rails, you
should isolate it in a small application which exposes the service
through an API (sinatra, grape, ...) and treat it as unreliable
because sometimes the PhantomJS crashes.

You should have enough CPU and memory to generate
thumbnails. See the issue #2 for the setup I'm using currently.

from webshot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.