From b2188e65c09cc7a620130c8d54c9370c254f5cc9 Mon Sep 17 00:00:00 2001 From: Daniel Werner Date: Fri, 2 Aug 2024 14:55:01 -0700 Subject: [PATCH] fix(agent): defend against graph-node bug #5550 (null paused) --- packages/indexer-common/src/graph-node.ts | 35 +++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/indexer-common/src/graph-node.ts b/packages/indexer-common/src/graph-node.ts index c61f69797..cbf311a86 100644 --- a/packages/indexer-common/src/graph-node.ts +++ b/packages/indexer-common/src/graph-node.ts @@ -153,18 +153,47 @@ export class GraphNode { ): Promise { try { this.logger.debug('Fetch subgraph deployment assignments') - const result = await this.status + + // FIXME: remove this initial check for just node when graph-node releases + // https://github.com/graphprotocol/graph-node/pull/5551 + const nodeOnlyResult = await this.status .query(gql` { indexingStatuses { subgraphDeployment: subgraph node - paused } } `) .toPromise() + if (nodeOnlyResult.error) { + throw nodeOnlyResult.error + } + + const withAssignments: string[] = nodeOnlyResult.data.indexingStatuses + .filter((result: QueryResult) => { + return result.node !== undefined + }) + .map((result: QueryResult) => { + return result.subgraphDeployment + }) + + const result = await this.status + .query( + gql` + { + indexingStatuses($subgraphs) { + subgraphDeployment: subgraph + node + paused + } + } + `, + { subgraphs: withAssignments }, + ) + .toPromise() + if (result.error) { throw result.error } @@ -178,7 +207,7 @@ export class GraphNode { type QueryResult = { subgraphDeployment: string - node: string + node: string | undefined paused: boolean | undefined }