phantomjs icon indicating copy to clipboard operation
phantomjs copied to clipboard

Using PhantomJs inside of clustering in an Express app causes AssertionError

Open RavenHursT opened this issue 11 years ago • 3 comments

Having trouble setting up a server that will allow me to visit webpages in phantom to do some tests on them (verify pixel calls are being made etc.).

Everything works as expected as long as I don't try to use node-cluster. I can make multiple requests to the endpoint and the processes never error out. But the moment I add clustering, the first request works just fine, but the second request always errors out and kills the script on page.create() and I get the following error in the node console:

assert.js:86
  throw new assert.AssertionError({
        ^
AssertionError: false == true
    at RoundRobinHandle.add (cluster.js:140:3)
    at queryServer (cluster.js:480:12)
    at Worker.onmessage (cluster.js:438:7)
    at ChildProcess.<anonymous> (cluster.js:692:8)
    at ChildProcess.emit (events.js:129:20)
    at handleMessage (child_process.js:324:10)
    at Pipe.channel.onread (child_process.js:352:11)

I'm rather new at this clustering stuff so I'm sure I'm doing something wrong.

Here's some code similar to what I'm trying to accomplish:

var numCPUs = require('os').cpus().length;
var cluster = require('cluster');

if (cluster.isMaster) {
    for (var i = 0; i < numCPUs; i++) {
        cluster.fork();
    }

    cluster.on('exit', function() {
        cluster.fork();
    });
} else {
    var
        express = require('express'),
        serve = express(),
        phantom = require('phantom');

    serve.get('/cs-rt-test-suite', function (req, res) {
        phantom.create();
    });
    serve.listen(8888);
}

RavenHursT avatar May 15 '15 01:05 RavenHursT

are you using node 0.10.38 or 0.11.x/0.12.x ? i downgraded back to 0.10.x to get rid of this bug, node is really buggy since 0.11.0

Darijusch avatar Jun 02 '15 14:06 Darijusch

@Darijusch, thought about doing that.. but I have other modules that depend on 0.12.x so I'm kinda stuck.. :-1:

RavenHursT avatar Jun 02 '15 18:06 RavenHursT

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

stale[bot] avatar Dec 30 '19 08:12 stale[bot]