@secondlayer/subgraphs 4.0.2 → 4.0.4

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) {
@@ -3385,5 +3400,5 @@ export {
3385
3400
  handleSubgraphReorg
3386
3401
  };
3387
3402
 
3388
- //# debugId=4BA27FCD8C456A6C64756E2164756E21
3403
+ //# debugId=483DE9E5A957DA2064756E2164756E21
3389
3404
  //# sourceMappingURL=reorg.js.map