1

Node PhantomJs throwing errors for 75+ concurrent requests , number of requests are bit irrelevant here.It's just issue is exposed at that point. I'm suspecting either requests are timing out or underlying sockets not playing well with nodeJs.I'm trying to pinpoint issue and would definitely appreciate any help.

Error logs :

phantom stdout:   :67 in onclose

phantom stdout: [WDS] Disconnected!


phantom stdout:   :67 in onclose

phantom stdout: TypeError: undefined is not an object (evaluating 'parent._jp.anxzqzn')

  http://localhost:9000/sockjs-node/592/4vgdvqkc/htmlfile?c=_jp.anxzqzn:8 in global code
TypeError: undefined is not an object (evaluating 'c.message')

  http://localhost:9000/sockjs-node/592/4vgdvqkc/htmlfile?c=_jp.anxzqzn:10 in p

phantom stdout: TypeError: undefined is not an object (evaluating 'c.message')

  http://localhost:9000/sockjs-node/592/4vgdvqkc/htmlfile?c=_jp.anxzqzn:10 in p
TypeError: undefined is not an object (evaluating 'c.message')

  http://localhost:9000/sockjs-node/592/4vgdvqkc/htmlfile?c=_jp.anxzqzn:10 in p

Node Server: ^0.10.40 5.3.0 stable

Tried with both node versions to verify ; it's not a NodeJs issue

Code Snippet :

page.open(decodedURL, function (status) {
                if (status !== "success") {
                    console.log("phantom app failed to respond");
                    response.statusCode = 400;
                    response.write('Unable to load url: ' + decodedURL);
                    response.end();
                    //Close page object as we're returning response
                    console.log("closing objects");
                    ph.exit()
                    //phantom.exit
                } else {
                    //Wait for all callback from the phantom app before rendering
                    console.log("Waiting for callback");
                    page.set('onCallback', function () {
                        //console.log("Callback name"+this.name);
                        console.log("received callback from app so rendering now");

                        renderImages();
                        /*else {
                         responseImages.push(page.renderBase64());
                         ph.exit()
                         }
                         */
                    });

                    // Otherwise wait for maxTimeout, unless invoked earlier by callback from app
                    //If we reach the max timeout we throw an error and just return
                    //This is because we don't want to return half loaded images back to the caller
                    //garbage collect page as well
                    var forceRenderTimeout = setTimeout(function () {
                        console.log("Reached the maximum timeout so returning 400");
                        response.statusCode = 400;
                        response.write('Unable to load url: ' + decodedURL);
                        response.end()
                        console.log("closing objects");
                        ph.exit()
                        //phantom.exit
                        //  page.close();
                    }, defaultOpts.maxTimeout);
                }
            });

PhantomJs: github.com/ariya/phantomjs PhantomJs_Node: github.com/sgentle/phantomjs-node

Callback mechanism being used in current code : phantomjs.org/api/webpage/handler/on-callback.html

vishal8492
  • 11
  • 2

0 Answers0