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

Adds missing close callback. #10

Merged
merged 1 commit into from
Jul 16, 2013
Merged

Conversation

johanneswuerbach
Copy link
Collaborator

In the latest version the example in the README is broken as the close callback was never executed. This PR adds a close callback.

sauceConnectProcess.close(function () {
  console.log("Closed Sauce Connect process");
});

@@ -190,7 +190,12 @@ function run(options, callback) {

openProcesses.push(child);

child.close = function () {
child.close = function (callback) {
child.on("close", function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't have to register the 'close' listener at all (if there is no callback).

@vojtajina
Copy link
Contributor

Also, you should make sure, that the callback in https://github.com/johanneswuerbach/sauce-connect-launcher/blob/3e30551295107cc0d531a6a656e9bc847328eb78/lib/sauce-connect-launcher.js#L186 is not called when killing the process. Eg. I call .close() and it exits with an error -> the original onStart callback would be called, that's wrong.

@johanneswuerbach
Copy link
Collaborator Author

@vojtajina right, I didn't saw that both callbacks are available in the scope. Fixed.

@vojtajina
Copy link
Contributor

@johanneswuerbach I meant something different. There are two callbacks you can register with sauce-connect-launcher:

  • when starting: var process = sauceConnect(opts, CALLBACK1)
  • when closing: process.close(CALLBACK2) (the one you are adding)

If an error happens when closing the process, both callbacks will be called. That's not correct, only the CALLBACK2 should get called. The CALLBACK1 should only get called if it starts successfully or if it fails to start - just once.

Hope this explains it better. Also, check my comment on the outdated diff.

@johanneswuerbach
Copy link
Collaborator Author

@vojtajina
Copy link
Contributor

@johanneswuerbach thanks, you are right, I missed this line!

bermi added a commit that referenced this pull request Jul 16, 2013
@bermi bermi merged commit 3866a00 into bermi:master Jul 16, 2013
@johanneswuerbach johanneswuerbach deleted the close-callback branch July 16, 2013 19:56
@vojtajina
Copy link
Contributor

@bermi thanks a lot!

Btw, are you guys following semver in any way ? Because these breaking changes in patch versions broke karma-sauce-launcher so I'm asking if you think it's better to set dep on fixed version of sauce-connect-launcher.

Thanks for your work ! Please ping me once this gets to NPM.

@bermi
Copy link
Owner

bermi commented Jul 16, 2013

@vojtajina from the commit history I have to admit that unfortunately we have not adhered to semver strictly. Thanks for bringing that to our attention, we will stick to semver from hereon.

BTW, 0.1.10 was pushed 1h ago

@vojtajina
Copy link
Contributor

@bermi Awesome, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants