test(server): unit-test SSE broadcast + client lifecycle (#273 follow-up) #285
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!285
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "test/s11-sse"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PR #273 s11 extraction follow-up. Covers
sse.ts.Coverage (11 tests)
addSSEListener: register/deliver, unsubscribe, throwing-listener eviction (3)broadcastSSE: fan-out, encoding, dropped-client cleanup,filter: null, filter scoping, dual-path HTTP+listener, empty-subscriber safety (7)SSE_HEARTBEAT_MS: constant sanity bounds (1)Behaviour surprises worth knowing
notifySSEListenerscatches throws, logs viaconsole.warn, and removes the offending listener mid-iteration. Same pattern for HTTP subscribers.broadcastSSE+notifySSEListeners) is deliberate — the JSDoc onnotifySSEListenerscalls out the split so sibling test files usingmock.module("./sse")can still reach the in-process bus.setIntervalheartbeat fires at module import. No way to clear/stop it without exporting the timer handle.filteris the mechanism behind/foreman/stream/:task_id— global/eventssubscribers carryfilter: null, scoped streams get a predicate.Sibling-file cleanup
Removed a stale
mock.module("./sse", () => ({ broadcastSSE: () => {} }))fromwebhook-post-merge.test.ts— it was process-globally replacing the real module (documented hazard insse.tsJSDoc). ThehandlePostMergeRebasecode path has no SSE subscribers registered in test config, so the real broadcast is a no-op there.webhook-post-merge.test.tsstill passes 4/4 in isolation.Checks
bunx tsc --noEmit -p apps/server/tsconfig.json— EXIT=0bun test apps/server/src/http/sse.test.ts— 11/11 pass