Skip to content
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

fix: ParentNamespace adapter broadcast bug #5009

Merged
merged 2 commits into from Apr 26, 2024

Conversation

gkt5015
Copy link
Contributor

@gkt5015 gkt5015 commented Apr 25, 2024

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

When a dynamic namespace emits to an individual socket, it will be met with an error:

node_modules/socket.io/dist/parent-namespace.js:88
        this.children.forEach((nsp) => {
                      ^

TypeError: Cannot read properties of undefined (reading 'forEach')
    at ParentBroadcastAdapter.broadcast (node_modules/socket.io/dist/parent-namespace.js:88:23)
    at BroadcastOperator.emit (node_modules/socket.io/dist/broadcast-operator.js:169:26)
    at Socket.<anonymous> (server.js:60:33)
    at Socket.emit (node:events:520:28)
    at Socket.emitReserved (node_modules/socket.io/dist/typed-events.js:56:22)
    at Socket._onclose (node_modules/socket.io/dist/socket.js:547:14)
    at Client.onclose (node_modules/socket.io/dist/client.js:247:20)
    at Socket.emit (node:events:532:35)
    at Socket.onClose (node_modules/engine.io/build/socket.js:304:18)
    at Object.onceWrapper (node:events:639:28)

New behavior

This fixes that error and adds a test that would guard this scenario.

Other information (e.g. related issues)

resolves #4985

@darrachequesne darrachequesne merged commit 239a2a8 into socketio:main Apr 26, 2024
12 checks passed
@darrachequesne
Copy link
Member

@gkt5015 awesome, thanks for the pull request 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

this.children is undefined for ParentBroadcastAdapter broadcast
2 participants