-
Notifications
You must be signed in to change notification settings - Fork 256
Fix #175 by removing system.exit calls in the built-in handlers #184
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
Conversation
🦋 Changeset detectedLatest commit: c4351fe The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I think the gotcha here is that just registering the
The same is true for the As a result, this PR will likely break apps that don't have their own handlers installed for those signals/events, because the presence of your handlers prevents them from exiting (which would be the normal/default Node.js behavior otherwise). On the flip side, including At the end of the day, the difficulty is really just that you're registering signal handlers in a library package 😅. The only way to do it "correctly", as far as I can tell, is for your handlers to exit the process if no other handlers are installed for the relevant signal/event, but not to exit the process if there is at least one other handler registered for the signal/event. That would more-or-less preserve the default Node.js behavior, as explained in the docs I linked above. |
Thanks for your comment; I will look into this later on. |
Added check logic within those SDK built-in listeners and changed the behavior to exit the process only when there are no other listeners. This does not change the current behavior for simple code snippets + resolves the unintuitive process termination for apps with custom listeners. |
This pull request resolves #175 and related reports. This commit 25165df in #45 introduced system.exit calls, which didn't exist before the fix. So, reverting them should make sense. An alternative approach would be to introduce a new flag env variable to turn this on/off but I don't think it's necessary.