Repository navigation
fix: don't release child namespace while a socket is still in middleware - #5588
Open
Jeremiah-D wants to merge 1 commit into
Open
Jeremiah-D wants to merge 1 commit into
Jeremiah-D wants to merge 1 commit into
Conversation
With cleanupEmptyChildNamespaces, a namespace was released as soon as sockets.size hit 0, even while another socket was still in its (async) middleware. That socket then joined the released object, the next connection got a new object under the same name, so broadcasts missed sockets and a later cleanup deleted the _nsps entry by name, unregistering the newer object while its sockets were still connected. Only clean up once both connected and pre-connect sockets are gone, and only delete the _nsps entry if it still points to the object being released. Fixes socketio#5587
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.
With cleanupEmptyChildNamespaces on, a child namespace was released as soon as sockets.size hit 0, even while another socket was still in its (async) middleware. That socket then joined the released object, the next connection got a new object under the same name, broadcasts missed sockets, and the later cleanup deleted the _nsps entry by name, unregistering the newer object while its sockets were still connected.
The fix only cleans up once both connected and pre-connect sockets are gone, and only deletes the _nsps entry if it still points to the object being released.
Verified with the repro from #5587 (adapted into a test in test/namespaces.ts): it fails before the fix and passes after. The full namespaces suite passes (45 passing); the full package suite has one pre-existing failure in test/close.ts ("should be able to close sio sending a srv", timeout) that also fails on unmodified main.
Fixes #5587