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

Better SIGINT handling in chrome-launcher #2959

Merged
merged 1 commit into from
Aug 17, 2017
Merged

Better SIGINT handling in chrome-launcher #2959

merged 1 commit into from
Aug 17, 2017

Conversation

mikecardwell
Copy link
Contributor

@mikecardwell mikecardwell commented Aug 12, 2017

This is a fix for #2797

Currently we add a SIGINT handler for each launched Chrome instance to kill that instance on exit. My change makes it so that we track the list of running Chrome instances. When that list goes from 0 to 1, a SIGINT handler is added which kills all tracked Chrome instances. When that list goes from 1 to 0, the handler is removed.

So there is only ever a maximum of one SIGINT listener, which prevents the EventEmitter memory leak warnings.

I believe that my fix is better than the other one provided in the issue as it allows for you to have more than 10 simultaneously running Chrome instances without an EventEmitter memory leak warning.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@mikecardwell
Copy link
Contributor Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@patrickhulce
Copy link
Collaborator

Thanks for the PR @mikecardwell! This lines up well with the approach @paulirish takes in #2616 of moving toward a manager for multiple instances.

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

yup this is much more straightforward.

process.exit(_SIGINT_EXIT_CODE);
});
if (opts.handleSIGINT && instances.size === 0) {
process.on(_SIGINT, sigintListener);

Choose a reason for hiding this comment

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

@paulirish @JoelEinbinder this gonna yield "max listeners" error in case of 11 simultaneously launched browsers.

Copy link
Contributor

Choose a reason for hiding this comment

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

instances is a global variable, so it only adds one listener per project.

Choose a reason for hiding this comment

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

ah i see. So the "handleSIGINT" option is not per-browser but per-process.

@mikecardwell mikecardwell deleted the chrome-launcher-sigint-handling branch November 28, 2017 10:16
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.

6 participants