OP-2481 Fixup

This commit is contained in:
Dmitry Leleko
2022-06-30 15:08:07 +03:00
parent 73eb2044da
commit ccff8058e5
2 changed files with 8 additions and 3 deletions

View File

@@ -74,6 +74,8 @@ export default class PriceFeedSubscription<T extends SubscriptionType = Subscrip
readonly type: T;
private isClosedIntentionally: boolean = false;
constructor(
type: T,
url: string,
@@ -108,7 +110,7 @@ export default class PriceFeedSubscription<T extends SubscriptionType = Subscrip
this.ws.onclose = (e) => {
if (this.heartbeatInterval) clearInterval(this.heartbeatInterval);
if (this.ws) this.init();
if (!this.isClosedIntentionally) this.init();
};
this.heartbeatInterval = setInterval(() => {
@@ -117,7 +119,7 @@ export default class PriceFeedSubscription<T extends SubscriptionType = Subscrip
}
kill() {
this.isClosedIntentionally = true;
this.ws?.close();
delete this.ws;
}
}