Skip to content
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
Closed

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

vojtajina opened this issue Apr 3, 2013 · 9 comments

Comments

@vojtajina
Copy link
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
Copy link

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
Copy link

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
Copy link
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
Copy link
Contributor Author

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

vojtajina added a commit that referenced this issue May 11, 2013
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
Copy link

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
Copy link

Should have mentioned I'm running Node v0.10.5

@vendethiel
Copy link

same here

@vojtajina
Copy link
Contributor Author

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
Copy link
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
Projects
None yet
Development

No branches or pull requests

6 participants