feat(connection): added handlers on open and close connections#2830
feat(connection): added handlers on open and close connections#2830
Conversation
There was a problem hiding this comment.
Pull request overview
Adds optional connection lifecycle hooks to the runtime-node WebSocket server so callers can run logic when a client connects or disconnects.
Changes:
- Extend
ILaunchHttpServerOptionswithonConnectionOpen/onConnectionClosecallbacks. - Register/execute connection and disconnection handlers in
WsServerHost. - Add a unit test validating both handlers are invoked.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| packages/runtime-node/test/node-env.manager.unit.ts | Adds a unit test covering open/close handler invocation |
| packages/runtime-node/src/ws-node-host.ts | Stores and triggers connection/disconnection handlers |
| packages/runtime-node/src/node-env-manager.ts | Wires server options into WsServerHost and disposes handlers |
| packages/runtime-node/src/launch-http-server.ts | Exposes new connection lifecycle hooks in server options |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
packages/runtime-node/src/launch-http-server.ts:1
- The new
onConnectionOpen/onConnectionCloseoptions introduce important lifecycle semantics but are undocumented. Adding brief JSDoc for when each callback is invoked (including the duplicate-connection replacement case), whetherclientIdis authenticated/validated at this point, and whatpostMessagecan be used for (e.g., whether it can target env IDs before registration) would make the API much clearer for consumers.
import express from 'express';
packages/runtime-node/src/ws-node-host.ts:1
- Given the explicit behavior of disconnecting an existing socket when the same
clientIdreconnects, it would be useful to add a unit test asserting the expectedonConnectionClosebehavior for the replaced socket. This will prevent regressions around whetheronConnectionCloseshould (or should not) fire when a client is immediately replaced by a new active connection.
import type io from 'socket.io';
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
why did you bump the version as part of this PR? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Subscribe to connection open, close.
Issue: https://github.com/dazl-dev/dazl/issues/6292