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

No rooms on client upgrade using uWebSockets.js #4443

Closed
stevestevensonneds opened this issue Aug 8, 2022 · 1 comment
Closed

No rooms on client upgrade using uWebSockets.js #4443

stevestevensonneds opened this issue Aug 8, 2022 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@stevestevensonneds
Copy link

Describe the bug

We're sometimes seeing a very rare upgrade error while using uWebSockets.js (uws);

TypeError: Cannot read properties of undefined (reading 'forEach')
    at subscribe (/node_modules/socket.io/dist/uws.js:87:11)
    at Socket.<anonymous> (/node_modules/socket.io/dist/uws.js:28:17)
    at Socket.emit (node:events:402:35)
    at WebSocket.onPacket (/node_modules/engine.io/build/socket.js:214:22)
    at WebSocket.emit (node:events:390:28)
    at WebSocket.onPacket (/node_modules/engine.io/build/transport.js:92:14)
    at WebSocket.onData (/node_modules/engine.io/build/transport.js:101:14)
    at message (/node_modules/engine.io/build/userver.js:56:30)"

Stack trace mapped to source

https://github.com/socketio/socket.io/blob/main/lib/uws.ts#L104
https://github.com/socketio/socket.io/blob/main/lib/uws.ts#L28
https://github.com/socketio/engine.io/blob/main/lib/socket.ts#L274
https://github.com/socketio/engine.io/blob/main/lib/transport.ts#L116
https://github.com/socketio/engine.io/blob/main/lib/transport.ts#L126
https://github.com/socketio/engine.io/blob/main/lib/userver.ts#L84

It seems to be when the client upgrades but is not in any rooms.

Expected behavior

Upgrade a connection without causing an error trying to subscribe to an omitted rooms argument.

Platform:

  • Client device: Unknown
  • Client OS: Unknown
  • Server: x86_64 & arm64 Alpine linux
  • Socket.IO version: 4.5.1
  • Engine.IO version: 6.2.0
  • uWebSockets.js version: 20.10.0
@stevestevensonneds stevestevensonneds added the to triage Waiting to be triaged by a member of the team label Aug 8, 2022
darrachequesne added a commit that referenced this issue Sep 2, 2022
This should fix a rare case where the Engine.IO connection was upgraded
to WebSocket while the Socket.IO socket was disconnected, which would
result in the following exception:

> TypeError: Cannot read properties of undefined (reading 'forEach')
>    at subscribe (/node_modules/socket.io/dist/uws.js:87:11)
>    at Socket.<anonymous> (/node_modules/socket.io/dist/uws.js:28:17)
>    at Socket.emit (node:events:402:35)
>    at WebSocket.onPacket (/node_modules/engine.io/build/socket.js:214:22)
>    at WebSocket.emit (node:events:390:28)
>    at WebSocket.onPacket (/node_modules/engine.io/build/transport.js:92:14)
>    at WebSocket.onData (/node_modules/engine.io/build/transport.js:101:14)
>    at message (/node_modules/engine.io/build/userver.js:56:30)

Related: #4443
@darrachequesne
Copy link
Member

I could indeed reproduce the issue, thanks a lot for the report 👍

This should be fixed by ba497ee, included in version 4.5.2.

Please reopen if needed.

@darrachequesne darrachequesne added bug Something isn't working and removed to triage Waiting to be triaged by a member of the team labels Sep 4, 2022
@darrachequesne darrachequesne added this to the 4.5.2 milestone Sep 4, 2022
dzad pushed a commit to dzad/socket.io that referenced this issue May 29, 2023
This should fix a rare case where the Engine.IO connection was upgraded
to WebSocket while the Socket.IO socket was disconnected, which would
result in the following exception:

> TypeError: Cannot read properties of undefined (reading 'forEach')
>    at subscribe (/node_modules/socket.io/dist/uws.js:87:11)
>    at Socket.<anonymous> (/node_modules/socket.io/dist/uws.js:28:17)
>    at Socket.emit (node:events:402:35)
>    at WebSocket.onPacket (/node_modules/engine.io/build/socket.js:214:22)
>    at WebSocket.emit (node:events:390:28)
>    at WebSocket.onPacket (/node_modules/engine.io/build/transport.js:92:14)
>    at WebSocket.onData (/node_modules/engine.io/build/transport.js:101:14)
>    at message (/node_modules/engine.io/build/userver.js:56:30)

Related: socketio#4443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants