New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launcher: handle spawn error, when binary does not exist #452

Closed
vojtajina opened this Issue Apr 3, 2013 · 9 comments

Comments

Projects
None yet
6 participants
@vojtajina
Contributor

vojtajina commented Apr 3, 2013

It looks like node 0.10 has changed behavior of child_process.spawn to throw an exception when the binary does not exist:

From #400

INFO [karma]: Karma server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
ERROR [karma]: { [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall:'spawn' }
Error: spawn ENOENT
at errnoException (child_process.js:948:11)
at Process.ChildProcess._handle.onexit (child_process.js:739:34)

We should handle that and display proper error message (can't find launcher binary, set env variable).

@vict-shevchenko

This comment has been minimized.

Show comment
Hide comment
@vict-shevchenko

vict-shevchenko Apr 4, 2013

I can confirm that setting env varible (User variable) CHROME_BIN to equal C:\Program Files\Google\Chrome\Application\chrome.exe resolves the problem well.
So it seems really problem with finding proper .exe

I can confirm that setting env varible (User variable) CHROME_BIN to equal C:\Program Files\Google\Chrome\Application\chrome.exe resolves the problem well.
So it seems really problem with finding proper .exe

@prasadgupte

This comment has been minimized.

Show comment
Hide comment
@prasadgupte

prasadgupte May 1, 2013

I'm facing this one on WinXP. Chrome was earlier installed in a user dir, pointing there failed. I then created a copy as per vict-shevchenko and set the CHROME_BIN var to point there, but that resulted in the same error. Do I need to create a web-server.js for this?

Sorry, I'm new to Angular / Git / Karma (just 2 hours old)

I'm facing this one on WinXP. Chrome was earlier installed in a user dir, pointing there failed. I then created a copy as per vict-shevchenko and set the CHROME_BIN var to point there, but that resulted in the same error. Do I need to create a web-server.js for this?

Sorry, I'm new to Angular / Git / Karma (just 2 hours old)

@timbertson

This comment has been minimized.

Show comment
Hide comment
@timbertson

timbertson May 3, 2013

Contributor

On linux, this bug puts the process in a bad state - you can't ctrl-c (terminate) it, I had to background it (ctrl-z) and use kill.

Contributor

timbertson commented May 3, 2013

On linux, this bug puts the process in a bad state - you can't ctrl-c (terminate) it, I had to background it (ctrl-z) and use kill.

@vojtajina

This comment has been minimized.

Show comment
Hide comment
@vojtajina

vojtajina May 11, 2013

Contributor

@gfxmonk yep, we need to handle this exception and this will be fine.

Contributor

vojtajina commented May 11, 2013

@gfxmonk yep, we need to handle this exception and this will be fine.

@vojtajina vojtajina closed this in 7d790b2 May 11, 2013

vojtajina added a commit that referenced this issue May 11, 2013

fix(launcher): handle ENOENT error, do not retry
If the binary does not exists:
- handle the error (Node 0.10+ throws unhandled error events)
- show nicer message
- do not retry

Closes #452
@flakey-bit

This comment has been minimized.

Show comment
Hide comment
@flakey-bit

flakey-bit May 13, 2013

Running Karma 0.8.0 on Windows 7, if my karma configuration has a single browser (and the binary does not exist), Karma hangs indefinitely. I see the following:

INFO [karma]: Karma server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
ERROR [karma]: { [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }
Error: spawn ENOENT
at errnoException (child_process.js:975:11)
at Process.ChildProcess._handle.onexit (child_process.js:766:34)

If there is more than one browser in my configuration then I get the message about not being able to invoke kill() on undefined.

NB I've worked-around the issue by throwing an error if self._process.pid == 0 after the spawn(). Don't think this is the NodeJS way to do it, but it works for me.

this._execCommand = function(cmd, args) {
log.debug(cmd + ' ' + args.join(' '));
self._process = spawn(cmd, args);
if (self._process.pid == 0) {
throw Error("Failed to start process: "+cmd);
}
var errorOutput = '';
self._process.stderr.on('data', function(data) {
errorOutput += data.toString();
});

self._process.on('close', function(code) {
  self._onProcessExit(code, errorOutput);
});

};

Running Karma 0.8.0 on Windows 7, if my karma configuration has a single browser (and the binary does not exist), Karma hangs indefinitely. I see the following:

INFO [karma]: Karma server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
ERROR [karma]: { [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }
Error: spawn ENOENT
at errnoException (child_process.js:975:11)
at Process.ChildProcess._handle.onexit (child_process.js:766:34)

If there is more than one browser in my configuration then I get the message about not being able to invoke kill() on undefined.

NB I've worked-around the issue by throwing an error if self._process.pid == 0 after the spawn(). Don't think this is the NodeJS way to do it, but it works for me.

this._execCommand = function(cmd, args) {
log.debug(cmd + ' ' + args.join(' '));
self._process = spawn(cmd, args);
if (self._process.pid == 0) {
throw Error("Failed to start process: "+cmd);
}
var errorOutput = '';
self._process.stderr.on('data', function(data) {
errorOutput += data.toString();
});

self._process.on('close', function(code) {
  self._onProcessExit(code, errorOutput);
});

};

@flakey-bit

This comment has been minimized.

Show comment
Hide comment
@flakey-bit

flakey-bit May 13, 2013

Should have mentioned I'm running Node v0.10.5

Should have mentioned I'm running Node v0.10.5

@vendethiel

This comment has been minimized.

Show comment
Hide comment

same here

@vojtajina

This comment has been minimized.

Show comment
Hide comment
@vojtajina

vojtajina Jun 17, 2013

Contributor

Guys, can you please update and check if it's fixed with 0.8.6 ?

Even if the binary is not set correctly, it should fail, but not hang indefinitely.

Contributor

vojtajina commented Jun 17, 2013

Guys, can you please update and check if it's fixed with 0.8.6 ?

Even if the binary is not set correctly, it should fail, but not hang indefinitely.

@timbertson

This comment has been minimized.

Show comment
Hide comment
@timbertson

timbertson Jun 19, 2013

Contributor

Yep, looks good to me on 0.8.6.

Contributor

timbertson commented Jun 19, 2013

Yep, looks good to me on 0.8.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment