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
Labels

Comments

@vojtajina
Copy link
Contributor

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

@vict-shevchenko vict-shevchenko commented 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

@prasadgupte
Copy link

@prasadgupte prasadgupte commented 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)

@timbertson
Copy link
Contributor

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

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

@flakey-bit flakey-bit commented 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);
});

};

@flakey-bit
Copy link

@flakey-bit flakey-bit commented May 13, 2013

Should have mentioned I'm running Node v0.10.5

@vendethiel
Copy link

@vendethiel vendethiel commented May 26, 2013

same here

@vojtajina
Copy link
Contributor Author

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

@timbertson 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.