Prevent destroyed providers from emitting network detection errors.

This commit is contained in:
Richard Moore 2023-08-15 03:07:03 -04:00
parent 30d3d6ee32
commit 7d4173049e

View File

@ -693,6 +693,7 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
try {
this.#network = await this._detectNetwork();
} catch (error) {
if (this.destroyed) { break; }
console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)");
this.emit("error", makeError("failed to bootstrap network detection", "NETWORK_ERROR", { event: "initial-network-discovery", info: { error } }));
await stall(1000);