Repository navigation
Fix listener leak on the shared port-probe server - #218
Open
faithfulojebiyi wants to merge 1 commit into
Open
faithfulojebiyi wants to merge 1 commit into
faithfulojebiyi wants to merge 1 commit into
Conversation
probePort reuses one net.Server and adds a once('listening') and a
once('error') listener per probe, but only one of the two fires, so the
other stays attached. Consecutive probes of the same kind accumulate them
until Node warns MaxListenersExceededWarning. Each handler now removes the
other.
This branch has not been deployed
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.
probePortreuses onenet.Serverand adds aonce('listening')and aonce('error')listener per probe, but only one of the two fires, so the other stays attached. Consecutive probes of the same kind (e.g. an app repeatedly proxying to a local port with nothing on::1) accumulate them until Node warns:and the listeners leak for the life of the process. (An
errorevent also clears staleerrorlisteners from earlier probes, so alternating results hide it; runs of the same result don't.)Each handler now removes the other.
The new
test/socket-util.spec.tsprobes 12 free and then 12 bound ports in a row and asserts noMaxListenersExceededWarning. It fails before this change (with the warning above, for botherrorandlistening) and passes after.test/integration/proxying/http-proxying.spec.tsstill passes (59 tests).