Remove unused broadcastToSession export from server/plugins/websocket.js #40

Closed
opened 2026-08-03 04:55:39 +00:00 by Jasper · 0 comments
Collaborator

Summary

broadcastToSession in server/plugins/websocket.js (line 46) is exported but never imported or called anywhere in the codebase — not in any route handler, plugin, utility, test, or client-side composable. It's dead code that should be removed to reduce maintenance burden and prevent developers from building on a non-existent broadcasting mechanism.

Acceptance criteria

  • broadcastToSession is removed from server/plugins/websocket.js
  • Its three dependencies (getSessionConnections, addSessionConnection, removeSessionConnection) remain, since they are actively used within the plugin for connection tracking (lines 138, 141, 158)
  • No other file imports or references broadcastToSession
  • All existing tests pass

Problem

I inspected server/plugins/websocket.js and confirmed that broadcastToSession is defined at line 46 as an exported function. A full search across the repository (including all .js files, test files, and composables) shows zero callers — no import, no dynamic import(), no usage in routes or plugins. The connection-tracking helpers it depends on (getSessionConnections, addSessionConnection, removeSessionConnection) are still actively used within the WebSocket plugin itself for per-session connection management, but the broadcast function that consumes those helpers is never invoked.

This dead code creates two risks:

  1. Developers may assume there's a working broadcast mechanism and build features on top of it.
  2. The exported API surface grows without corresponding test coverage or usage, increasing the cost of future refactoring.

Proposed work

  • Delete broadcastToSession (lines 46–53) from server/plugins/websocket.js.
  • Keep getSessionConnections, addSessionConnection, and removeSessionConnection — they are used internally at lines 138, 141, and 158.
## Summary `broadcastToSession` in `server/plugins/websocket.js` (line 46) is exported but never imported or called anywhere in the codebase — not in any route handler, plugin, utility, test, or client-side composable. It's dead code that should be removed to reduce maintenance burden and prevent developers from building on a non-existent broadcasting mechanism. ## Acceptance criteria - `broadcastToSession` is removed from `server/plugins/websocket.js` - Its three dependencies (`getSessionConnections`, `addSessionConnection`, `removeSessionConnection`) remain, since they are actively used within the plugin for connection tracking (lines 138, 141, 158) - No other file imports or references `broadcastToSession` - All existing tests pass ## Problem I inspected `server/plugins/websocket.js` and confirmed that `broadcastToSession` is defined at line 46 as an exported function. A full search across the repository (including all `.js` files, test files, and composables) shows zero callers — no `import`, no dynamic `import()`, no usage in routes or plugins. The connection-tracking helpers it depends on (`getSessionConnections`, `addSessionConnection`, `removeSessionConnection`) are still actively used within the WebSocket plugin itself for per-session connection management, but the broadcast function that consumes those helpers is never invoked. This dead code creates two risks: 1. Developers may assume there's a working broadcast mechanism and build features on top of it. 2. The exported API surface grows without corresponding test coverage or usage, increasing the cost of future refactoring. ## Proposed work - Delete `broadcastToSession` (lines 46–53) from `server/plugins/websocket.js`. - Keep `getSessionConnections`, `addSessionConnection`, and `removeSessionConnection` — they are used internally at lines 138, 141, and 158. <!-- jasper-fp:2052804a32d2ecc2 -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: keligrubb/kestrelos#40