Skip to content

Broadcast: Cannot read properties of undefined (reading 'Sender') on ws_1.WebSocket.Sender #478

Closed
@offaxis

Description

@offaxis

Hi !

I used to broadcast socket and worked fine ! But a new error appeared on calling client.broadcast.emit('hello');

Error:

/.../node_modules/socket.io-adapter/dist/index.js:170
            packetOpts.wsPreEncodedFrame = ws_1.WebSocket.Sender.frame(data, {
                                                          ^

TypeError: Cannot read properties of undefined (reading 'Sender')
    at RedisAdapter._encode (/.../node_modules/socket.io-adapter/dist/index.js:170:59)
    at RedisAdapter.broadcast (/.../node_modules/socket.io-adapter/dist/index.js:117:37)
    at RedisAdapter.broadcast (/.../node_modules/@socket.io/redis-adapter/dist/index.js:466:15)
    at BroadcastOperator.emit (/.../node_modules/socket.io/dist/broadcast-operator.js:169:26)
    at Socket.<anonymous> (/.../server/api/user/user.socket.js:19:34)
    at Socket.emit (node:events:513:28)
    at Socket.emit (node:domain:489:12)
    at Socket.emitUntyped (/.../node_modules/socket.io/dist/typed-events.js:69:22)
    at /.../node_modules/socket.io/dist/socket.js:614:39
    at processTicksAndRejections (node:internal/process/task_queues:77:11)

If i remove the broadcast instruction like client.emit('hello'); it works! But the current client received it too...

Versions:
"@socket.io/redis-adapter": "^8.0.0", // same issue with v7
"socket.io": "^4.5.4",
"socket.io-client": "^4.5.4",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions