Skip to content

Conversation

@idoros
Copy link
Contributor

@idoros idoros commented Nov 5, 2025

This pull request introduces needed improvements to the websocket client-server communication, especially around client reconnections and resource cleanup. The changes implement a stable client identification mechanism, delayed disposal of client resources to handle transient disconnects, and improved test coverage for these scenarios.

WebSocket client and server:

  • Added a stable client ID (stableClientId) to WsClientHost, sent during authentication, enabling the server to reliably identify and manage reconnecting clients.
  • WsServerHost now tracks clients using the stable client ID, namespaces environment IDs, and implements delayed disposal logic. If a client disconnects, a timer is started; if the client reconnects before the timer expires, disposal is canceled, otherwise, dispose messages are emitted for all associated env IDs.

API and Event:

  • The subscribers event emitter on WsClientHost now includes a connect event
  • The disconnect event provides a reason string.
  • New methods disconnectSocket, reconnectSocket, and isConnected have been added for explicit socket control and connection status checks.

Tests:

  • Added tests in node-com.unit.ts to cover reconnection scenarios, delayed dispose logic, and to ensure communication remains functional after reconnects or disposes.

@idoros idoros self-assigned this Nov 5, 2025
@idoros idoros requested a review from barak007 November 5, 2025 13:35
@AviVahl
Copy link
Contributor

AviVahl commented Nov 5, 2025

It's not closing... Specific to this branch (not in main).

@AviVahl AviVahl merged commit c2c1489 into main Nov 6, 2025
6 checks passed
@AviVahl AviVahl deleted the ido/make-reconnect-exist branch November 6, 2025 14:39
AviVahl added a commit that referenced this pull request Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants