Skip to content

Crash Nodejs phantom-node phantomjs #11201

Open
Identity-labs opened this Issue Apr 3, 2013 · 12 comments

4 participants

@Identity-labs

I use phantomjs with bridge for nodejs.

When I opening a web page on google : http://www.google.fr/search?q=g4&pws=0&aq=t
I have a crash report, the dmp file is here: http://g4-dev.fr/6065b782-8033-1d29-1d7c2dcc-36e778ad.dmp

I don't have a status or a console log err

page.open(parsingUrl, function(err,status) {
    if(err)
        console.log(err);
    console.log("opened site: ", status);

Best regard

@JamesMGreene
Collaborator

Being that there isn't any "phantom-node" NPM module, what is the actual NPM module name of the bridge you are using?

  • node-phantom
  • phantom (a.k.a. phantomjs-node)
  • phantom-proxy
  • phantomjs
  • phantomstream
  • grunt-lib-phantomjs
  • etc.
@Identity-labs

Sorry for the misunderstand, it's node-phantom, install by NPM.

After several test, I think the problem is an iframe in page, crash phantom.
I test several version, it's a same (1.7.0, 1.8.0, 1.8.2, 1.9.0)

Thanks for your time 👍

@ariya
Owner
ariya commented Apr 14, 2013

Can you reduce this to a simple PhantomJS script which reproduces the issue?

@Identity-labs

I post code example here: http://pastebin.com/RJBz8KV9

@Identity-labs

If I use phantomjs without nodejs, it's work correctly.
You have an idea of problem ?

@Identity-labs

I find the problem.
If css directive with this spécification.
On google search page

#gbql,#gbgsi,#gbgsa,.gbqfi,.gbmai,.gbp0i,.gbmppci,.gbqfh #gbql {
background-image: url('//ssl.gstatic.com/gb/images/k1_a31af7ac.png');
}

@JamesMGreene
Collaborator

@Identity-labs:
If it still holds true that your script works fine when you use PhantomJS directly but fails when using the Node wrapper, then you should close this bug and just track the corresponding bug in node-phantom's issue tracker: alexscheelmeyer/node-phantom#59

If that is no longer true, please clarify the state of things. Thanks!

@alexscheelmeyer

Hi! Author of node-phantom here. I have debugged this and found I can recreate it without the node wrapper also. Instead of it dumping a crash dump file though, I get this

RangeError: Maximum call stack size exceeded.

phantomjs://bootstrap.js:56

So perhaps some kind of infinite recursion?

Anyway this code below recreates this problem on my macbook.

var webpage=require('webpage');
var controlpage=webpage.create();

setupPushNotifications(0,controlpage);
controlpage.content='<html><body><select>\n</select>\n<span style="background-image: url(http://phantomjs.org/images/phantomjs-logo.png);">crash</span>\n</body>\n</html>';

function setupPushNotifications(id, page) {
    var callbacks=['onAlert','onConfirm','onConsoleMessage','onError','onInitialized','onLoadFinished',
                   'onLoadStarted','onPrompt','onResourceRequested','onResourceReceived','onResourceError',
                   'onUrlChanged','onCallback'];
    function push(notification){
        controlpage.evaluate('function(){socket.emit("push",'+JSON.stringify(notification)+');}');
    }
    callbacks.forEach(function(cb) {
        page[cb]=function(parm){
            var notification=Array.prototype.slice.call(arguments);
            if((cb==='onResourceRequested')&&(parm.url.indexOf('data:image')===0)) return;

            push([id, cb, notification]);
        };
    });
}
@JamesMGreene
Collaborator

@alexscheelmeyer There isn't a socket on that page, so it seems like your example code would throw errors.

@alexscheelmeyer

I agree it would throw errors, but not the "Maximum call stack size exceeded" kind, right?

There is no socket because I tried to make the smallest amount of code that would recreate a problem.

On closer inspection it might not be the same problem I have have recreated though - seems to reach that call stack size regardless of the actual content that is set on the page now.

@alexscheelmeyer

I have tried to debug this some more and I think if you really need to recreate it without the node-wrapper you need some other way of serving the socket.io code as it seems to be related to a combination of the given html-content and the setting up of callbacks (push notifications).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.