From cc00d66e680923c399d6d858d99dfba8aa48a850 Mon Sep 17 00:00:00 2001 From: Eldar Gabdullin Date: Wed, 9 Aug 2023 01:18:03 +0400 Subject: [PATCH] allow to configure archive timeout and increase it to 180 seconds by default --- .../evm-processor/master_2023-08-08-21-19.json | 10 ++++++++++ evm/evm-processor/src/processor.ts | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 common/changes/@subsquid/evm-processor/master_2023-08-08-21-19.json diff --git a/common/changes/@subsquid/evm-processor/master_2023-08-08-21-19.json b/common/changes/@subsquid/evm-processor/master_2023-08-08-21-19.json new file mode 100644 index 000000000..ae10693b1 --- /dev/null +++ b/common/changes/@subsquid/evm-processor/master_2023-08-08-21-19.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@subsquid/evm-processor", + "comment": "allow to configure archive request timeout and increase the default up to 180 seconds", + "type": "minor" + } + ], + "packageName": "@subsquid/evm-processor" +} \ No newline at end of file diff --git a/evm/evm-processor/src/processor.ts b/evm/evm-processor/src/processor.ts index 6347aa195..aada5ecc9 100644 --- a/evm/evm-processor/src/processor.ts +++ b/evm/evm-processor/src/processor.ts @@ -32,11 +32,17 @@ type ChainRpc = string | { } +type ArchiveConnection = string | { + url: string + requestTimeout?: number +} + + interface ArchiveDataSource { /** * Subsquid evm archive endpoint URL */ - archive: string + archive: ArchiveConnection /** * Chain node RPC endpoint URL */ @@ -298,15 +304,20 @@ export class EvmBatchProcessor { @def private getArchiveDataSource(): EvmArchive { + let archive = assertNotNull(this.getDataSource().archive) + if (typeof archive == 'string') { + archive = {url: archive} + } + let http = new HttpClient({ - baseUrl: assertNotNull(this.getDataSource().archive), + baseUrl: archive.url, headers: { 'x-squid-id': this.getSquidId() }, agent: new HttpAgent({ keepAlive: true }), - httpTimeout: 30_000, + httpTimeout: archive.requestTimeout || 180_000, retryAttempts: Number.MAX_SAFE_INTEGER, log: this.getLogger().child('archive') })