Skip to content

Commit 7cf82e6

Browse files
committed
ensure downstream unsubscribe on upstream cleanup
1 parent f6fc8f1 commit 7cf82e6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/json-rpc/upstream/server.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ export function createUpstreamServer({
4848

4949
function cleanup() {
5050
if (reconnectTimer) clearTimeout(reconnectTimer);
51+
for (const [_, unsub] of unsubscribers) {
52+
try {
53+
unsub();
54+
} catch {
55+
//
56+
}
57+
}
58+
5159
unsubscribers.clear();
5260
states.clear();
5361
subscriptions.abort();

src/json-rpc/upstream/shared.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ function _createSharedSubscription(
281281
//
282282
}
283283

284+
try {
285+
onLocalUnsubscribe(localId);
286+
} catch {
287+
//
288+
}
289+
284290
localSubs.delete(localId);
285291

286292
try {

0 commit comments

Comments
 (0)