diff --git a/src/model/Observables/ChainSpec.ts b/src/model/Observables/ChainSpec.ts index ce54167190..ac8d71c93f 100644 --- a/src/model/Observables/ChainSpec.ts +++ b/src/model/Observables/ChainSpec.ts @@ -28,11 +28,13 @@ export class ChainSpec implements ObservableGetSubscription { // Handle subscription failure. const error = async () => { + this.unsubscribe(); reject(null); }; // Handle completion. const complete = async () => { + this.unsubscribe(); resolve(this.#value); }; @@ -68,6 +70,7 @@ export class ChainSpec implements ObservableGetSubscription { this.#unsub = subscription.unsubscribe; } catch (e) { + this.unsubscribe(); reject(null); } }); diff --git a/src/model/Observables/TaggedMetadata.ts b/src/model/Observables/TaggedMetadata.ts index f5077f00b9..68d29b826c 100644 --- a/src/model/Observables/TaggedMetadata.ts +++ b/src/model/Observables/TaggedMetadata.ts @@ -29,11 +29,13 @@ export class TaggedMetadata implements ObservableGetSubscription { // Handle subscription failure. const error = async () => { + this.unsubscribe(); reject(null); }; // Handle completion. const complete = async () => { + this.unsubscribe(); resolve(this.#value); }; @@ -68,6 +70,7 @@ export class TaggedMetadata implements ObservableGetSubscription { this.#unsub = subscription.unsubscribe; } catch (e) { + this.unsubscribe(); reject(null); } });