Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

Commit

Permalink
add worker error message into error returned from manager
Browse files Browse the repository at this point in the history
  • Loading branch information
bjrmatos committed Apr 24, 2017
1 parent dc69811 commit 1b8648a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 6 additions & 5 deletions lib/phantomManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ PhantomManager.prototype.start = function (cb) {
var started = 0;
var workerErrors = [];
var couldNotStartWorkersErr;
var workerMainErrorMsg = '';

for (var i = 0; i < self.options.numberOfWorkers; i++) {
self._phantomInstances.push(new PhantomWorker({
Expand All @@ -51,14 +52,18 @@ PhantomManager.prototype.start = function (cb) {
}));
self._phantomInstances[i].start(function(err) {
if (err) {
if (err.mainReason && workerMainErrorMsg === '') {
workerMainErrorMsg = err.mainReason;
}

workerErrors.push(err);
}

started++;

if (started === self.options.numberOfWorkers) {
if (workerErrors.length) {
couldNotStartWorkersErr = new Error("phantom manager could not start all workers..");
couldNotStartWorkersErr = new Error("phantom manager could not start all workers.." + workerMainErrorMsg);
couldNotStartWorkersErr.workerErrors = workerErrors;
return cb(couldNotStartWorkersErr);
}
Expand Down Expand Up @@ -152,7 +157,3 @@ PhantomManager.prototype.tryFlushQueue = function () {

this._executeInWorker(freePhantomInstance, task.options, task.cb);
};




9 changes: 7 additions & 2 deletions lib/phantomWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@ PhantomWorker.prototype.start = function (cb) {

//we send host and port as env vars to child process
self._childProcess = childProcess.execFile(self.options.phantomPath, childArgs, childOpts, function (error, stdout, stderr) {
var segFaultMsg;

if (error) {
if (error.signal === 'SIGSEGV') {
error.message = (
error.message + ', Segmentation fault error: if you are using macOS Sierra with phantomjs < 2 remember that ' +
segFaultMsg = (
'Segmentation fault error: if you are using macOS Sierra with phantomjs < 2 remember that ' +
'phantomjs < 2 does not work there and has bugs (https://github.com/ariya/phantomjs/issues/14558), ' +
'try to upgrade to phantom 2 if using macOS Sierra'
);

error.message = error.message + ', ' + segFaultMsg;
error.mainReason = segFaultMsg;
}

startError = error
Expand Down

0 comments on commit 1b8648a

Please sign in to comment.