Skip to content

Commit 799dee7

Browse files
fix: scoped close should not tear down shared bus (P1) #10 (#11)
ScopedBusTui.close() previously called inner.close(), which closed the shared WebSocket connection and broke every other consumer of the same parent bus. A scoped view is a channel-namespace wrapper, not a connection owner — its close() must be a no-op. Also adds an explicit close() override on ScopedBusClient. The base BusClient had no close() method, so ScopedBusClient was inheriting nothing — but that becomes a footgun the moment the base class gains lifecycle management (HTTP keep-alive pooling, binary shutdown). Added a no-op close() on the base BusClient to document the contract and let ScopedBusClient override it cleanly. Regression test in test/scoped-close.test.ts: 3 cases, all pass with the fix and all fail without it (verified via git stash).
1 parent 75c3e9a commit 799dee7

8 files changed

Lines changed: 134 additions & 11 deletions

File tree

‎dist/bus-client.d.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ export declare class BusClient {
4343
healthCheck(): Promise<boolean>;
4444
/** The port the bus is running on (0 = in-memory mode) */
4545
get activePort(): number;
46+
/**
47+
* Close the client. No-op for plain HTTP clients — each call already uses
48+
* a fresh request. Defined here so ScopedBusClient can override it as a
49+
* no-op without accidentally inheriting a future lifecycle teardown.
50+
*/
51+
close(): void;
4652
/** Returns a scoped client that prefixes all channels with {service}/ */
4753
forService(name: string): BusClient;
4854
/** Returns a scoped client that prefixes all channels with {sessionId}/ */

‎dist/index.js‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)