diff --git a/CHANGELOG.md b/CHANGELOG.md index bb9b8e5691..b54808e617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Changes: - Contract reads will now expose an additional `gasRequired` (total estimated) - Allow schedule derives to handle scheduler entries that cannot decode - Add missing historic `Heartbeat: HeartbeatTo244` mapping to Westend +- Adjust Ws `.disconnect()` logic to always clear auto-connect - Add `BlockNumberFor` type mapping - Add Westend 9080 upgrade block - Add `derive.crowdloan.contributions(paraId)` diff --git a/packages/rpc-provider/src/ws/index.ts b/packages/rpc-provider/src/ws/index.ts index 2ef5767729..2684bf232d 100644 --- a/packages/rpc-provider/src/ws/index.ts +++ b/packages/rpc-provider/src/ws/index.ts @@ -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 public async disconnect (): Promise { + // switch off autoConnect, we are in manual mode now + this.#autoConnectMs = 0; + try { - assert(!isNull(this.#websocket), 'Cannot disconnect on a non-connected websocket'); - - // switch off autoConnect, we are in manual mode now - this.#autoConnectMs = 0; - - // 1000 - Normal closure; the connection successfully completed - this.#websocket.close(1000); + if (this.#websocket) { + // 1000 - Normal closure; the connection successfully completed + this.#websocket.close(1000); + } } catch (error) { l.error(error);