diff --git a/common/protocol/src/index.ts b/common/protocol/src/index.ts index 07676bbc..cfcd6c9f 100644 --- a/common/protocol/src/index.ts +++ b/common/protocol/src/index.ts @@ -47,7 +47,7 @@ import { isStorageBalanceLow, } from "./methods"; import { ICacheProvider, IMetrics, IRuntime } from "./types"; -import { standardizeError } from "./utils"; +import { IDLE_TIME, sleep, standardizeError } from "./utils"; import { SupportedChains } from "@kyvejs/sdk/dist/constants"; import { storageProviderFactory } from "./reactors/storageProviders"; import { compressionFactory } from "./reactors/compression"; @@ -317,6 +317,11 @@ export class Validator { process.exit(1); } + // until data is not available we wait and idle + while (!(await this.isDataAvailable())) { + await sleep(IDLE_TIME); + } + if (!(await this.isDataAvailable())) { process.exit(1); } diff --git a/common/protocol/src/methods/checks/isDataAvailable.ts b/common/protocol/src/methods/checks/isDataAvailable.ts index 51588cb4..478538d7 100644 --- a/common/protocol/src/methods/checks/isDataAvailable.ts +++ b/common/protocol/src/methods/checks/isDataAvailable.ts @@ -45,8 +45,8 @@ export async function isDataAvailable(this: Validator): Promise { return true; } catch (err) { - this.logger.fatal(`Data not available. Exiting ...`); - this.logger.fatal(standardizeError(err)); + this.logger.warn(`Data not available for next key. Retrying in 60s ...`); + this.logger.debug(standardizeError(err)); return false; }