Skip to content

Commit

Permalink
common: improve auto-graft-sync error logging, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dwerner committed Feb 20, 2025
1 parent bc2b580 commit d1f9408
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
29 changes: 18 additions & 11 deletions packages/indexer-common/src/graph-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,10 @@ export class GraphNode {
}

/**
* wait for the block to be synced, polling indexing status until it is
* Wait for the block to be synced, polling indexing status until it is
* The Deployment should already be created and deployed to graph-node
* This will resume a paused subgraph if the block height target is higher than the
* current block height
*/
public async syncToBlockAndPause(
blockHeight: number,
Expand All @@ -833,9 +836,12 @@ export class GraphNode {
let deployed: SubgraphDeploymentAssignment[] = []
let attempt = 0

const maxAttempts = 5
const waitTimeMs = 3000

// wait and poll for the assignment to be created.
while (attempt < 5) {
await waitForMs(3000)
while (attempt < maxAttempts) {
await waitForMs(waitTimeMs)
deployed = await this.subgraphDeploymentAssignmentsByDeploymentID(
SubgraphStatus.ALL,
[subgraphDeployment.ipfsHash],
Expand All @@ -853,13 +859,14 @@ export class GraphNode {
deployed,
})
attempt += 1
}

if (attempt >= 5) {
this.logger.error(`Subgraph not deployed and active`, {
subgraph: subgraphDeployment.ipfsHash,
})
throw new Error(`Subgraph not deployed and active, cannot sync to block`)
if (attempt >= maxAttempts) {
this.logger.error(`Subgraph not deployed and active`, {
subgraph: subgraphDeployment.ipfsHash,
})
throw new Error(
`Subgraph ${subgraphDeployment.ipfsHash} not deployed and active after ${maxAttempts} attempts, cannot sync to block ${blockHeight}`,
)
}
}

const indexingStatus = await this.indexingStatus([subgraphDeployment])
Expand Down Expand Up @@ -927,7 +934,7 @@ export class GraphNode {
indexingStatus,
},
)
await waitForMs(3000)
await waitForMs(waitTimeMs)
}

this.logger.debug(`End syncing subgraph deployment synced to block`, {
Expand Down
2 changes: 1 addition & 1 deletion packages/indexer-common/src/indexer-management/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export class ActionManager {
if (pendingActions.length > 0) {
logger.warn(
`${pendingActions} Actions found in PENDING state when execution began. Was there a crash?` +
`These indicate that execution was interrupted while calling contracts, and will need to be cleared manually.`,
`These indicate that execution was interrupted while calling contracts, and will need to be cleared manually.`,
)
}

Expand Down

0 comments on commit d1f9408

Please sign in to comment.