Only add one process.exit handler#179
Closed
benlowry wants to merge 1 commit intobubenshchykov:masterfrom
Closed
Conversation
Owner
|
Thanks for reporting! There is a guard that prevents spawning two processes in parallel https://github.com/bubenshchykov/ngrok/blob/master/process.js#L18 Thus, we can be assigning only one process.on('exit', .. ) handler at a time. The use-case that you describe is: start process; kill process; start process; kill process - true, it will lead to multiple exit handlers and a memory leak. So the problem boils down to simply calling process.removeListener(cb) inside exit callback, what do you think? |
philnash
added a commit
to philnash/ngrok
that referenced
this pull request
Jul 26, 2021
Also, stop performing an asynchronous action on process exit. It is not officially supported. However subprocess.kill is not asynchronous, so can be used over the internal killProcess method. Fixes bubenshchykov#239. Should help bubenshchykov#231. Supersedes bubenshchykov#179
Collaborator
|
Thanks for this, I'm closing in favour of #240, in which we definitely only set up the listener once and don't need to introduce more state. I wouldn't have thought of it without this PR as inspiration though. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If you create short-lived tunnels then each time it binds a method to the process.on('exit') until error messages start being emitted -