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

Empty session injected into $onDisconnect #2383

Closed
derevnjuk opened this issue Jul 13, 2023 · 2 comments · Fixed by #2384
Closed

Empty session injected into $onDisconnect #2383

derevnjuk opened this issue Jul 13, 2023 · 2 comments · Fixed by #2384
Assignees

Comments

@derevnjuk
Copy link
Contributor

Information

  • Version: 7.x
  • Packages: @tsed/socketio

The @SocketSession consistently injects an empty Map when invoking the $onDisconnect handler. This issue arises due to the utilization of floating promises while invoking the handlers without awaiting the result before destroying the session. To rectify this problem, it is recommended to await the execution of the $onConnection and $onDisconnect methods.

Steps to reproduce:

  1. Utilize the SocketIOModule.
  2. Create a SocketService service, implementing the $onDisconnect event handler.
  3. Inject the session into both $onDisconnect and $onConnection event handlers using the @SocketSession
  4. Set something into the session on the $onConnection

Example

@SocketService("/room")
export class Room {
  $onConnection(@Socket socket: Socket, @SocketSession session: SocketSession) {
    session.set('id', socket.id);
  }

  $onDisconnect(@SocketSession session: SocketSession) {
    console.log(session.size) // outputs 0
  }
}

Expected result:
The session must be preserved on the $onDisconnect.

@github-actions
Copy link

🎉 Are you happy?

If you appreciated the support, know that it is free and is carried out on personal time ;)

A support, even a little bit makes a difference for me and continues to bring you answers!

github opencollective

@Romakita
Copy link
Collaborator

🎉 This issue has been resolved in version 7.33.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants