Adjust Ws .disconnect() logic to always clear auto-connect (#3749)

This commit is contained in:
Jaco
2021-07-09 06:14:30 +02:00
committed by GitHub
parent e13a7ff5a1
commit 445a080f7d
2 changed files with 9 additions and 8 deletions
+1
View File
@@ -11,6 +11,7 @@ Changes:
- Contract reads will now expose an additional `gasRequired` (total estimated) - Contract reads will now expose an additional `gasRequired` (total estimated)
- Allow schedule derives to handle scheduler entries that cannot decode - Allow schedule derives to handle scheduler entries that cannot decode
- Add missing historic `Heartbeat: HeartbeatTo244` mapping to Westend - Add missing historic `Heartbeat: HeartbeatTo244` mapping to Westend
- Adjust Ws `.disconnect()` logic to always clear auto-connect
- Add `BlockNumberFor` type mapping - Add `BlockNumberFor` type mapping
- Add Westend 9080 upgrade block - Add Westend 9080 upgrade block
- Add `derive.crowdloan.contributions(paraId)` - Add `derive.crowdloan.contributions(paraId)`
+8 -8
View File
@@ -215,18 +215,18 @@ export class WsProvider implements ProviderInterface {
} }
/** /**
* @description Manually disconnect from the connection, clearing autoconnect logic * @description Manually disconnect from the connection, clearing auto-connect logic
*/ */
// eslint-disable-next-line @typescript-eslint/require-await // eslint-disable-next-line @typescript-eslint/require-await
public async disconnect (): Promise<void> { public async disconnect (): Promise<void> {
// switch off autoConnect, we are in manual mode now
this.#autoConnectMs = 0;
try { try {
assert(!isNull(this.#websocket), 'Cannot disconnect on a non-connected websocket'); if (this.#websocket) {
// 1000 - Normal closure; the connection successfully completed
// switch off autoConnect, we are in manual mode now this.#websocket.close(1000);
this.#autoConnectMs = 0; }
// 1000 - Normal closure; the connection successfully completed
this.#websocket.close(1000);
} catch (error) { } catch (error) {
l.error(error); l.error(error);