Repository navigation
fix: #598 clean up a worker that already exited before terminate - #601
Open
akashchamp wants to merge 1 commit into
Open
akashchamp wants to merge 1 commit into
akashchamp wants to merge 1 commit into
Conversation
…nate When an abort listener rejects, the worker exits by itself. The pool then called terminate() and waited for an exit event that had already been emitted, so the worker stayed busy forever and pool.terminate() hung. Remember when the worker has exited and clean it up right away in terminate(). This covers both process and thread workers.
Contributor
|
Thanks @akashchamp your implementation seems to model my comment regarding the exit event. I cannot approve but I agree with the implementation. |
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.
Fixes #598.
When an abort listener rejects, the worker exits on its own. The cleanup timeout then calls
terminate(), which waits for anexitevent that was already emitted, so the handler stayscleaningforever: the worker counts as busy, queued tasks never run andpool.terminate()hangs.The handler now records when its worker has exited, and
terminate()cleans up right away in that case. This uses the handler's ownexitlistener rather thanexitCode, so it also works forworker_threads, which hang the same way.Added a test for both
processandthreadworkers whose abort listener rejects. Both time out on master and pass with the fix.npm testpasses on Node 22 and 24 (172 passing). The reproduction from the issue now printsbusyWorkers: 0, thenpong, andpool.terminate()resolves, for both worker types.