@secondlayer/subgraphs 4.0.1 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1653,6 +1653,7 @@ function matchSources(sources, transactions, events, traitContracts = new Map, f
1653
1653
  // src/runtime/block-processor.ts
1654
1654
  import { getTargetDb } from "@secondlayer/shared/db";
1655
1655
  import { resolveTraitContractIds } from "@secondlayer/shared/db/queries/contracts";
1656
+ import { recordGapBatch } from "@secondlayer/shared/db/queries/subgraph-gaps";
1656
1657
  import { advanceOperationCursor } from "@secondlayer/shared/db/queries/subgraph-operations";
1657
1658
  import {
1658
1659
  recordLiveError,
@@ -2805,6 +2806,19 @@ async function processBlock(subgraph, subgraphName, blockHeight, opts) {
2805
2806
  throw new LiveCursorRaceLostError(subgraphName, blockHeight);
2806
2807
  }
2807
2808
  }
2809
+ if (rr.errors > 0 && !rewind) {
2810
+ if (opts?.subgraphId) {
2811
+ await recordGapBatch(tx, opts.subgraphId, subgraphName, [
2812
+ { start: blockHeight, end: blockHeight, reason: "processing_error" }
2813
+ ]);
2814
+ } else {
2815
+ logger7.warn("Block errors not recorded as a gap — no subgraphId", {
2816
+ subgraph: subgraphName,
2817
+ blockHeight,
2818
+ errors: rr.errors
2819
+ });
2820
+ }
2821
+ }
2808
2822
  if (rr.processed > 0 || rr.errors > 0) {
2809
2823
  const lastError = rr.errors > 0 ? `${rr.errors} error(s) at block ${blockHeight}` : undefined;
2810
2824
  await recordSubgraphProcessed(tx, subgraphName, rr.processed, rr.errors, lastError);
@@ -3196,7 +3210,8 @@ async function catchUpSubgraph(subgraph, subgraphName) {
3196
3210
  throw new ReorgEpochChangedError(subgraphName);
3197
3211
  }
3198
3212
  return processBlockWithRetry(subgraph, subgraphName, height, {
3199
- preloaded
3213
+ preloaded,
3214
+ subgraphId: subgraphRow.id
3200
3215
  });
3201
3216
  });
3202
3217
  } catch (err) {
@@ -3255,7 +3270,7 @@ async function catchUpSubgraph(subgraph, subgraphName) {
3255
3270
  import { getErrorMessage as getErrorMessage3 } from "@secondlayer/shared";
3256
3271
  import { getRawClient, getTargetDb as getTargetDb3 } from "@secondlayer/shared/db";
3257
3272
  import {
3258
- recordGapBatch,
3273
+ recordGapBatch as recordGapBatch2,
3259
3274
  resolveGaps
3260
3275
  } from "@secondlayer/shared/db/queries/subgraph-gaps";
3261
3276
  import {
@@ -3538,7 +3553,7 @@ async function processBlockRange(def, opts) {
3538
3553
  }
3539
3554
  if (batchFailedBlocks.length > 0 && opts.subgraphId) {
3540
3555
  const gaps = coalesceFailedBlocks(batchFailedBlocks);
3541
- await recordGapBatch(targetDb, opts.subgraphId, subgraphName, gaps).catch((err) => {
3556
+ await recordGapBatch2(targetDb, opts.subgraphId, subgraphName, gaps).catch((err) => {
3542
3557
  logger10.warn("Failed to record subgraph gaps", {
3543
3558
  subgraph: subgraphName,
3544
3559
  error: err instanceof Error ? err.message : String(err)
@@ -3811,5 +3826,5 @@ export {
3811
3826
  backfillSubgraph
3812
3827
  };
3813
3828
 
3814
- //# debugId=DBF968F790C7362964756E2164756E21
3829
+ //# debugId=9051620A82B8B7F264756E2164756E21
3815
3830
  //# sourceMappingURL=reindex.js.map