Skip to content

Commit

Permalink
Check for autoConnectMs on reconnect (polkadot-js#3151)
Browse files Browse the repository at this point in the history
* Check for autoConnectMs on reconnect

* Update packages/rpc-provider/src/ws/index.ts
  • Loading branch information
jacogr authored Feb 5, 2021
1 parent 8fe262a commit 94d26c7
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/rpc-provider/src/ws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,16 @@ export class WsProvider implements ProviderInterface {
* @description Connect, never throwing an error, but rather forcing a retry
*/
public async connectWithRetry (): Promise<void> {
try {
await this.connect();
} catch (error) {
setTimeout((): void => {
this.connectWithRetry().catch((): void => {
// does not throw
});
}, this.#autoConnectMs || RETRY_DELAY);
if (this.#autoConnectMs > 0) {
try {
await this.connect();
} catch (error) {
setTimeout((): void => {
this.connectWithRetry().catch((): void => {
// does not throw
});
}, this.#autoConnectMs);
}
}
}

Expand Down

0 comments on commit 94d26c7

Please sign in to comment.