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

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

Projects

None yet

6 participants

@vojtajina
Contributor

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

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

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
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.

@vojtajina
Contributor

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

@vojtajina vojtajina added a commit that closed this issue May 11, 2013
@vojtajina vojtajina 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
7d790b2
@vojtajina vojtajina closed this in 7d790b2 May 11, 2013
@vojtajina vojtajina added a commit that referenced this issue May 11, 2013
@vojtajina vojtajina 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
df4ffc7
@eddiewould

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);
});

};

@eddiewould

Should have mentioned I'm running Node v0.10.5

@vendethiel

same here

@vojtajina
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.

@timbertson
Contributor

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