From c45935e29ca0dd1ecdf1277fa1107246041be580 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Tue, 16 Apr 2024 21:32:34 -0400 Subject: [PATCH] Do not send unsubscribe messages to destroyed Providers (#4678). --- src.ts/providers/provider-socket.ts | 1 + src.ts/providers/subscriber-filterid.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src.ts/providers/provider-socket.ts b/src.ts/providers/provider-socket.ts index e5ec69f4e2..db14b70e84 100644 --- a/src.ts/providers/provider-socket.ts +++ b/src.ts/providers/provider-socket.ts @@ -69,6 +69,7 @@ export class SocketSubscriber implements Subscriber { stop(): void { (>(this.#filterId)).then((filterId) => { + if (this.#provider.destroyed) { return; } this.#provider.send("eth_unsubscribe", [ filterId ]); }); this.#filterId = null; diff --git a/src.ts/providers/subscriber-filterid.ts b/src.ts/providers/subscriber-filterid.ts index 466cc2ce78..ecc1334d48 100644 --- a/src.ts/providers/subscriber-filterid.ts +++ b/src.ts/providers/subscriber-filterid.ts @@ -118,6 +118,7 @@ export class FilterIdSubscriber implements Subscriber { if (filterIdPromise) { this.#filterIdPromise = null; filterIdPromise.then((filterId) => { + if (this.#provider.destroyed) { return; } this.#provider.send("eth_uninstallFilter", [ filterId ]); }); }