@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.
@@ -470,6 +470,11 @@ interface ProcessBlockOptions {
470
470
  * forward write. Never set this outside `reorg.ts`.
471
471
  */
472
472
  reorgRewind?: true;
473
+ /** The subgraph row's uuid. Required to record a gap row when a block
474
+ * processes with handler errors — `subgraph_gaps.subgraph_id` is NOT NULL.
475
+ * Absent on paths that pass `skipProgressUpdate` (they record gaps
476
+ * themselves, see reindex.ts). */
477
+ subgraphId?: string;
473
478
  }
474
479
  /** Default per-block retry schedule before a failure counts as persistent. */
475
480
  declare const BLOCK_RETRY_DELAYS_MS: number[];
@@ -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);
@@ -2926,5 +2940,5 @@ export {
2926
2940
  BLOCK_RETRY_DELAYS_MS
2927
2941
  };
2928
2942
 
2929
- //# debugId=94D930A6B3A998FE64756E2164756E21
2943
+ //# debugId=903EE944B43D271764756E2164756E21
2930
2944
  //# sourceMappingURL=block-processor.js.map