@secondlayer/shared 11.15.0 → 11.15.2

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.
@@ -33,6 +33,11 @@ type DiskGuardOptions = {
33
33
  sleep?: (ms: number) => Promise<void>
34
34
  readSpace?: (path: string) => Promise<DiskSpace>
35
35
  };
36
+ /** 100GB: comfortably above the ~39GB an needs plus the backup spike.
37
+ * Exported as the fallback threshold for callers (the canonical exporter)
38
+ * that derive a tighter, size-aware requirement once they have a previous
39
+ * snapshot to measure, and only fall back to this fixed number cold. */
40
+ declare const DEFAULT_MIN_FREE_BYTES: number;
36
41
  declare class DiskSpaceExhausted extends Error {
37
42
  constructor(free: number, required: number, waitedMs: number);
38
43
  }
@@ -43,4 +48,4 @@ declare class DiskSpaceExhausted extends Error {
43
48
  * start — because the pressure that matters arrives mid-job.
44
49
  */
45
50
  declare function waitForDiskSpace(options: DiskGuardOptions): Promise<void>;
46
- export { DiskGuardOptions, DiskSpace, DiskSpaceExhausted, readDiskSpace, waitForDiskSpace };
51
+ export { DEFAULT_MIN_FREE_BYTES, DiskGuardOptions, DiskSpace, DiskSpaceExhausted, readDiskSpace, waitForDiskSpace };
@@ -44,10 +44,11 @@ async function waitForDiskSpace(options) {
44
44
  }
45
45
  }
46
46
  export {
47
+ DEFAULT_MIN_FREE_BYTES,
47
48
  DiskSpaceExhausted,
48
49
  readDiskSpace,
49
50
  waitForDiskSpace
50
51
  };
51
52
 
52
- //# debugId=F4103F3B5631788664756E2164756E21
53
+ //# debugId=4DC8DC7AB2DD7E6F64756E2164756E21
53
54
  //# sourceMappingURL=disk-guard.js.map
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/archive/disk-guard.ts"],
4
4
  "sourcesContent": [
5
- "import { statfs } from \"node:fs/promises\";\n\n/**\n * Free-space guard for bulk archive jobs.\n *\n * Twice on 2026-08-12 a bulk job filled the disk that production Postgres\n * shares: a backfill died at 9.2M/14.4M rows on ENOSPC, and a restore died at\n * 86% of events. Prod survived both, but only just — 2.9GB free with the\n * indexer still ingesting.\n *\n * The failure mode that makes this worth guarding rather than monitoring: the\n * nightly `pg_basebackup` transiently consumes ~150GB, so a job that starts\n * with comfortable headroom can still hit the wall an hour later. Checking\n * once at startup is not enough; the check has to be repeated as the job runs.\n *\n * Waiting is the right response, not failing. The spike passes, and an\n * archive job that pauses for twenty minutes is strictly better than one that\n * dies at 86% or, worse, takes the database down with it.\n */\n\nexport type DiskSpace = { freeBytes: number; totalBytes: number };\n\nexport async function readDiskSpace(path: string): Promise<DiskSpace> {\n\tconst stats = await statfs(path);\n\treturn {\n\t\tfreeBytes: stats.bavail * stats.bsize,\n\t\ttotalBytes: stats.blocks * stats.bsize,\n\t};\n}\n\nexport type DiskGuardOptions = {\n\t/** Any path on the filesystem to watch. */\n\tpath: string;\n\t/** Pause below this many bytes free. */\n\tminFreeBytes?: number;\n\t/** How long to wait between re-checks while paused. */\n\tpollMs?: number;\n\t/** Give up after this long rather than pausing forever. */\n\tmaxWaitMs?: number;\n\tonPause?: (free: DiskSpace, waitedMs: number) => void;\n\tsleep?: (ms: number) => Promise<void>;\n\treadSpace?: (path: string) => Promise<DiskSpace>;\n};\n\n/** 100GB: comfortably above the ~39GB an export needs plus the backup spike. */\nconst DEFAULT_MIN_FREE_BYTES = 100 * 1024 ** 3;\nconst DEFAULT_POLL_MS = 60_000;\nconst DEFAULT_MAX_WAIT_MS = 2 * 3_600_000;\n/**\n * A threshold larger than a share of the whole disk is unsatisfiable, not\n * protective: on a 14GB CI runner or a modest VPS, demanding 100GB free would\n * block forever waiting for space that machine can never have. The absolute\n * default is tuned for the production host; this keeps it from becoming a wall\n * everywhere else.\n */\nconst MAX_THRESHOLD_FRACTION_OF_DISK = 0.25;\n\nfunction effectiveThreshold(configured: number, totalBytes: number): number {\n\tif (!Number.isFinite(totalBytes) || totalBytes <= 0) return configured;\n\treturn Math.min(configured, totalBytes * MAX_THRESHOLD_FRACTION_OF_DISK);\n}\n\nexport class DiskSpaceExhausted extends Error {\n\tconstructor(free: number, required: number, waitedMs: number) {\n\t\tsuper(\n\t\t\t`only ${(free / 1024 ** 3).toFixed(1)}GB free (need ${(required / 1024 ** 3).toFixed(1)}GB) after waiting ${Math.round(waitedMs / 60_000)}m`,\n\t\t);\n\t\tthis.name = \"DiskSpaceExhausted\";\n\t}\n}\n\n/**\n * Block until there is enough headroom, or throw after `maxWaitMs`.\n *\n * Call this between units of work — before each partition, not once at the\n * start — because the pressure that matters arrives mid-job.\n */\nexport async function waitForDiskSpace(\n\toptions: DiskGuardOptions,\n): Promise<void> {\n\tconst minFree = options.minFreeBytes ?? DEFAULT_MIN_FREE_BYTES;\n\tconst pollMs = options.pollMs ?? DEFAULT_POLL_MS;\n\tconst maxWaitMs = options.maxWaitMs ?? DEFAULT_MAX_WAIT_MS;\n\tconst readSpace = options.readSpace ?? readDiskSpace;\n\tconst sleep =\n\t\toptions.sleep ??\n\t\t((ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms)));\n\n\tlet waited = 0;\n\twhile (true) {\n\t\tconst space = await readSpace(options.path);\n\t\tconst threshold = effectiveThreshold(minFree, space.totalBytes);\n\t\tif (space.freeBytes >= threshold) return;\n\t\tif (waited >= maxWaitMs) {\n\t\t\tthrow new DiskSpaceExhausted(space.freeBytes, threshold, waited);\n\t\t}\n\t\toptions.onPause?.(space, waited);\n\t\tawait sleep(pollMs);\n\t\twaited += pollMs;\n\t}\n}\n"
5
+ "import { statfs } from \"node:fs/promises\";\n\n/**\n * Free-space guard for bulk archive jobs.\n *\n * Twice on 2026-08-12 a bulk job filled the disk that production Postgres\n * shares: a backfill died at 9.2M/14.4M rows on ENOSPC, and a restore died at\n * 86% of events. Prod survived both, but only just — 2.9GB free with the\n * indexer still ingesting.\n *\n * The failure mode that makes this worth guarding rather than monitoring: the\n * nightly `pg_basebackup` transiently consumes ~150GB, so a job that starts\n * with comfortable headroom can still hit the wall an hour later. Checking\n * once at startup is not enough; the check has to be repeated as the job runs.\n *\n * Waiting is the right response, not failing. The spike passes, and an\n * archive job that pauses for twenty minutes is strictly better than one that\n * dies at 86% or, worse, takes the database down with it.\n */\n\nexport type DiskSpace = { freeBytes: number; totalBytes: number };\n\nexport async function readDiskSpace(path: string): Promise<DiskSpace> {\n\tconst stats = await statfs(path);\n\treturn {\n\t\tfreeBytes: stats.bavail * stats.bsize,\n\t\ttotalBytes: stats.blocks * stats.bsize,\n\t};\n}\n\nexport type DiskGuardOptions = {\n\t/** Any path on the filesystem to watch. */\n\tpath: string;\n\t/** Pause below this many bytes free. */\n\tminFreeBytes?: number;\n\t/** How long to wait between re-checks while paused. */\n\tpollMs?: number;\n\t/** Give up after this long rather than pausing forever. */\n\tmaxWaitMs?: number;\n\tonPause?: (free: DiskSpace, waitedMs: number) => void;\n\tsleep?: (ms: number) => Promise<void>;\n\treadSpace?: (path: string) => Promise<DiskSpace>;\n};\n\n/** 100GB: comfortably above the ~39GB an export needs plus the backup spike.\n * Exported as the fallback threshold for callers (the canonical exporter)\n * that derive a tighter, size-aware requirement once they have a previous\n * snapshot to measure, and only fall back to this fixed number cold. */\nexport const DEFAULT_MIN_FREE_BYTES: number = 100 * 1024 ** 3;\nconst DEFAULT_POLL_MS = 60_000;\nconst DEFAULT_MAX_WAIT_MS = 2 * 3_600_000;\n/**\n * A threshold larger than a share of the whole disk is unsatisfiable, not\n * protective: on a 14GB CI runner or a modest VPS, demanding 100GB free would\n * block forever waiting for space that machine can never have. The absolute\n * default is tuned for the production host; this keeps it from becoming a wall\n * everywhere else.\n */\nconst MAX_THRESHOLD_FRACTION_OF_DISK = 0.25;\n\nfunction effectiveThreshold(configured: number, totalBytes: number): number {\n\tif (!Number.isFinite(totalBytes) || totalBytes <= 0) return configured;\n\treturn Math.min(configured, totalBytes * MAX_THRESHOLD_FRACTION_OF_DISK);\n}\n\nexport class DiskSpaceExhausted extends Error {\n\tconstructor(free: number, required: number, waitedMs: number) {\n\t\tsuper(\n\t\t\t`only ${(free / 1024 ** 3).toFixed(1)}GB free (need ${(required / 1024 ** 3).toFixed(1)}GB) after waiting ${Math.round(waitedMs / 60_000)}m`,\n\t\t);\n\t\tthis.name = \"DiskSpaceExhausted\";\n\t}\n}\n\n/**\n * Block until there is enough headroom, or throw after `maxWaitMs`.\n *\n * Call this between units of work — before each partition, not once at the\n * start — because the pressure that matters arrives mid-job.\n */\nexport async function waitForDiskSpace(\n\toptions: DiskGuardOptions,\n): Promise<void> {\n\tconst minFree = options.minFreeBytes ?? DEFAULT_MIN_FREE_BYTES;\n\tconst pollMs = options.pollMs ?? DEFAULT_POLL_MS;\n\tconst maxWaitMs = options.maxWaitMs ?? DEFAULT_MAX_WAIT_MS;\n\tconst readSpace = options.readSpace ?? readDiskSpace;\n\tconst sleep =\n\t\toptions.sleep ??\n\t\t((ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms)));\n\n\tlet waited = 0;\n\twhile (true) {\n\t\tconst space = await readSpace(options.path);\n\t\tconst threshold = effectiveThreshold(minFree, space.totalBytes);\n\t\tif (space.freeBytes >= threshold) return;\n\t\tif (waited >= maxWaitMs) {\n\t\t\tthrow new DiskSpaceExhausted(space.freeBytes, threshold, waited);\n\t\t}\n\t\toptions.onPause?.(space, waited);\n\t\tawait sleep(pollMs);\n\t\twaited += pollMs;\n\t}\n}\n"
6
6
  ],
7
- "mappings": ";AAAA;AAsBA,eAAsB,aAAa,CAAC,MAAkC;AAAA,EACrE,MAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,EAC/B,OAAO;AAAA,IACN,WAAW,MAAM,SAAS,MAAM;AAAA,IAChC,YAAY,MAAM,SAAS,MAAM;AAAA,EAClC;AAAA;AAkBD,IAAM,yBAAyB,MAAM,QAAQ;AAC7C,IAAM,kBAAkB;AACxB,IAAM,sBAAsB,IAAI;AAQhC,IAAM,iCAAiC;AAEvC,SAAS,kBAAkB,CAAC,YAAoB,YAA4B;AAAA,EAC3E,IAAI,CAAC,OAAO,SAAS,UAAU,KAAK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4DC8DC7AB2DD7E6F64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -417,6 +417,39 @@ interface Pox5EventsTable {
417
417
  source_cursor: string;
418
418
  created_at: Generated<Date>;
419
419
  }
420
+ interface Pox5CyclesTable {
421
+ reward_cycle: number;
422
+ start_burn_height: number;
423
+ prepare_start_burn_height: number;
424
+ end_burn_height: number;
425
+ total_stacked_ustx: string;
426
+ reward_eligible_ustx: string;
427
+ stakers: number;
428
+ signers_in_set: number;
429
+ /** bond index (as string) -> sats staked for this cycle. */
430
+ bond_sats: unknown;
431
+ bond_total_sats: string;
432
+ sbtc_custodied_sats: string;
433
+ rewards_allocated_stx: string;
434
+ rewards_allocated_bond: string;
435
+ reserve_deposit: string;
436
+ rewards_per_token_stx: string | null;
437
+ /** bond index (as string) -> cumulative rewards-per-sat for this cycle. */
438
+ rewards_per_token_bond: unknown;
439
+ distributions: number;
440
+ rewards_claimed: string;
441
+ computed_through_height: number;
442
+ updated_at: Generated<Date>;
443
+ }
444
+ interface Pox5CycleSignersTable {
445
+ reward_cycle: number;
446
+ signer: string;
447
+ delegated_ustx: string;
448
+ stx_only_ustx: string;
449
+ reward_shares_ustx: string;
450
+ in_set: boolean;
451
+ rewards_claimed: string;
452
+ }
420
453
  interface BurnBlockRewardsTable {
421
454
  cursor: string;
422
455
  burn_block_height: number;
@@ -764,6 +797,8 @@ interface Database {
764
797
  chain_reorgs: ChainReorgsTable;
765
798
  pox4_calls: Pox4CallsTable;
766
799
  pox5_events: Pox5EventsTable;
800
+ pox5_cycles: Pox5CyclesTable;
801
+ pox5_cycle_signers: Pox5CycleSignersTable;
767
802
  burn_block_rewards: BurnBlockRewardsTable;
768
803
  burn_block_reward_slots: BurnBlockRewardSlotsTable;
769
804
  sbtc_events: SbtcEventsTable;
@@ -417,6 +417,39 @@ interface Pox5EventsTable {
417
417
  source_cursor: string;
418
418
  created_at: Generated<Date>;
419
419
  }
420
+ interface Pox5CyclesTable {
421
+ reward_cycle: number;
422
+ start_burn_height: number;
423
+ prepare_start_burn_height: number;
424
+ end_burn_height: number;
425
+ total_stacked_ustx: string;
426
+ reward_eligible_ustx: string;
427
+ stakers: number;
428
+ signers_in_set: number;
429
+ /** bond index (as string) -> sats staked for this cycle. */
430
+ bond_sats: unknown;
431
+ bond_total_sats: string;
432
+ sbtc_custodied_sats: string;
433
+ rewards_allocated_stx: string;
434
+ rewards_allocated_bond: string;
435
+ reserve_deposit: string;
436
+ rewards_per_token_stx: string | null;
437
+ /** bond index (as string) -> cumulative rewards-per-sat for this cycle. */
438
+ rewards_per_token_bond: unknown;
439
+ distributions: number;
440
+ rewards_claimed: string;
441
+ computed_through_height: number;
442
+ updated_at: Generated<Date>;
443
+ }
444
+ interface Pox5CycleSignersTable {
445
+ reward_cycle: number;
446
+ signer: string;
447
+ delegated_ustx: string;
448
+ stx_only_ustx: string;
449
+ reward_shares_ustx: string;
450
+ in_set: boolean;
451
+ rewards_claimed: string;
452
+ }
420
453
  interface BurnBlockRewardsTable {
421
454
  cursor: string;
422
455
  burn_block_height: number;
@@ -764,6 +797,8 @@ interface Database {
764
797
  chain_reorgs: ChainReorgsTable;
765
798
  pox4_calls: Pox4CallsTable;
766
799
  pox5_events: Pox5EventsTable;
800
+ pox5_cycles: Pox5CyclesTable;
801
+ pox5_cycle_signers: Pox5CycleSignersTable;
767
802
  burn_block_rewards: BurnBlockRewardsTable;
768
803
  burn_block_reward_slots: BurnBlockRewardSlotsTable;
769
804
  sbtc_events: SbtcEventsTable;
@@ -734,6 +734,39 @@ interface Pox5EventsTable {
734
734
  source_cursor: string;
735
735
  created_at: Generated<Date>;
736
736
  }
737
+ interface Pox5CyclesTable {
738
+ reward_cycle: number;
739
+ start_burn_height: number;
740
+ prepare_start_burn_height: number;
741
+ end_burn_height: number;
742
+ total_stacked_ustx: string;
743
+ reward_eligible_ustx: string;
744
+ stakers: number;
745
+ signers_in_set: number;
746
+ /** bond index (as string) -> sats staked for this cycle. */
747
+ bond_sats: unknown;
748
+ bond_total_sats: string;
749
+ sbtc_custodied_sats: string;
750
+ rewards_allocated_stx: string;
751
+ rewards_allocated_bond: string;
752
+ reserve_deposit: string;
753
+ rewards_per_token_stx: string | null;
754
+ /** bond index (as string) -> cumulative rewards-per-sat for this cycle. */
755
+ rewards_per_token_bond: unknown;
756
+ distributions: number;
757
+ rewards_claimed: string;
758
+ computed_through_height: number;
759
+ updated_at: Generated<Date>;
760
+ }
761
+ interface Pox5CycleSignersTable {
762
+ reward_cycle: number;
763
+ signer: string;
764
+ delegated_ustx: string;
765
+ stx_only_ustx: string;
766
+ reward_shares_ustx: string;
767
+ in_set: boolean;
768
+ rewards_claimed: string;
769
+ }
737
770
  interface BurnBlockRewardsTable {
738
771
  cursor: string;
739
772
  burn_block_height: number;
@@ -1081,6 +1114,8 @@ interface Database {
1081
1114
  chain_reorgs: ChainReorgsTable;
1082
1115
  pox4_calls: Pox4CallsTable;
1083
1116
  pox5_events: Pox5EventsTable;
1117
+ pox5_cycles: Pox5CyclesTable;
1118
+ pox5_cycle_signers: Pox5CycleSignersTable;
1084
1119
  burn_block_rewards: BurnBlockRewardsTable;
1085
1120
  burn_block_reward_slots: BurnBlockRewardSlotsTable;
1086
1121
  sbtc_events: SbtcEventsTable;
@@ -418,6 +418,39 @@ interface Pox5EventsTable {
418
418
  source_cursor: string;
419
419
  created_at: Generated<Date>;
420
420
  }
421
+ interface Pox5CyclesTable {
422
+ reward_cycle: number;
423
+ start_burn_height: number;
424
+ prepare_start_burn_height: number;
425
+ end_burn_height: number;
426
+ total_stacked_ustx: string;
427
+ reward_eligible_ustx: string;
428
+ stakers: number;
429
+ signers_in_set: number;
430
+ /** bond index (as string) -> sats staked for this cycle. */
431
+ bond_sats: unknown;
432
+ bond_total_sats: string;
433
+ sbtc_custodied_sats: string;
434
+ rewards_allocated_stx: string;
435
+ rewards_allocated_bond: string;
436
+ reserve_deposit: string;
437
+ rewards_per_token_stx: string | null;
438
+ /** bond index (as string) -> cumulative rewards-per-sat for this cycle. */
439
+ rewards_per_token_bond: unknown;
440
+ distributions: number;
441
+ rewards_claimed: string;
442
+ computed_through_height: number;
443
+ updated_at: Generated<Date>;
444
+ }
445
+ interface Pox5CycleSignersTable {
446
+ reward_cycle: number;
447
+ signer: string;
448
+ delegated_ustx: string;
449
+ stx_only_ustx: string;
450
+ reward_shares_ustx: string;
451
+ in_set: boolean;
452
+ rewards_claimed: string;
453
+ }
421
454
  interface BurnBlockRewardsTable {
422
455
  cursor: string;
423
456
  burn_block_height: number;
@@ -765,6 +798,8 @@ interface Database {
765
798
  chain_reorgs: ChainReorgsTable;
766
799
  pox4_calls: Pox4CallsTable;
767
800
  pox5_events: Pox5EventsTable;
801
+ pox5_cycles: Pox5CyclesTable;
802
+ pox5_cycle_signers: Pox5CycleSignersTable;
768
803
  burn_block_rewards: BurnBlockRewardsTable;
769
804
  burn_block_reward_slots: BurnBlockRewardSlotsTable;
770
805
  sbtc_events: SbtcEventsTable;
@@ -1963,6 +1998,8 @@ declare const TABLE_TO_DB: {
1963
1998
  decoder_checkpoints: string
1964
1999
  pox4_calls: string
1965
2000
  pox5_events: string
2001
+ pox5_cycles: string
2002
+ pox5_cycle_signers: string
1966
2003
  burn_block_rewards: string
1967
2004
  burn_block_reward_slots: string
1968
2005
  sbtc_events: string
@@ -2083,4 +2120,15 @@ declare function getRawClient(role?: "source" | "target"): ReturnType<typeof pos
2083
2120
  declare function getRawClientFor(url: string): ReturnType<typeof postgres>;
2084
2121
  /** Close all DB connection pools. Call in CLI commands to allow process exit. */
2085
2122
  declare function closeDb(): Promise<void>;
2086
- export { Account, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiKey, ApiKeysTable, ArchiveFetch, ArchiveFetchesTable, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, ChainReadCacheTable, ChainReorgsTable, Contract, ContractsTable, CoverageSegmentsTable, Database, DbPlane, DbReadRow, DbSplitStatus, DeadLetterEventsTable, DecodedEventsTable, DecoderCheckpointsTable, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, IndexColumn, IndexColumnType, IndexPrimaryKey, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountCredits, InsertAccountSpendCap, InsertApiKey, InsertArchiveFetch, InsertBlock, InsertContract, InsertEvent, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, InstancesTable, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, MigrationRole, NativeClock, NumericAsText, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RepairMode, RetryState, RunStatus, SOURCE_READ_COLUMNS, SOURCE_READ_PKS, SOURCE_READ_TYPES, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, Subgraph, SubgraphGap, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, TABLE_TO_DB, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UsageLedgerRow, UsageLedgerTable, VmEvent, VmEventsArchiveTable, VmEventsTable, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookFormat, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookRuntime, WebhookStatus, WebhooksTable, applicationDatabaseUrl, assertDbSplit, closeDb, describeDbUrl, getDb, getDbSplitStatus, getMigrationRole, getRawClient, getRawClientFor, getSourceDb, getTargetDb, jsonb, onChainPlane, onControlPlane, parseJsonb, resolveSourceUrl, resolveTargetUrl, setMigrationRole, sql };
2123
+ /**
2124
+ * `closeDb()`, but never let it block process exit past `timeoutMs`.
2125
+ *
2126
+ * 2026-09-28: a canonical printed its summary and then sat idle for 20
2127
+ * minutes — 0% CPU, `wchan=ep_poll`, one open socket — stuck in `await
2128
+ * closeDb()`. Only the wrapper's own 6h timeout moved things along. A driver
2129
+ * holding a socket open past `.destroy()`/`.end()` finishing (or never
2130
+ * finishing at all) must not stop a one-shot script from exiting once its
2131
+ * actual work is done.
2132
+ */
2133
+ declare function closeDbOrTimeout(timeoutMs?: number, closeFn?: () => Promise<void>): Promise<void>;
2134
+ export { Account, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiKey, ApiKeysTable, ArchiveFetch, ArchiveFetchesTable, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, ChainReadCacheTable, ChainReorgsTable, Contract, ContractsTable, CoverageSegmentsTable, Database, DbPlane, DbReadRow, DbSplitStatus, DeadLetterEventsTable, DecodedEventsTable, DecoderCheckpointsTable, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, IndexColumn, IndexColumnType, IndexPrimaryKey, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountCredits, InsertAccountSpendCap, InsertApiKey, InsertArchiveFetch, InsertBlock, InsertContract, InsertEvent, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, InstancesTable, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, MigrationRole, NativeClock, NumericAsText, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RepairMode, RetryState, RunStatus, SOURCE_READ_COLUMNS, SOURCE_READ_PKS, SOURCE_READ_TYPES, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, Subgraph, SubgraphGap, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, TABLE_TO_DB, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UsageLedgerRow, UsageLedgerTable, VmEvent, VmEventsArchiveTable, VmEventsTable, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookFormat, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookRuntime, WebhookStatus, WebhooksTable, applicationDatabaseUrl, assertDbSplit, closeDb, closeDbOrTimeout, describeDbUrl, getDb, getDbSplitStatus, getMigrationRole, getRawClient, getRawClientFor, getSourceDb, getTargetDb, jsonb, onChainPlane, onControlPlane, parseJsonb, resolveSourceUrl, resolveTargetUrl, setMigrationRole, sql };
@@ -744,6 +744,8 @@ var TABLE_TO_DB = {
744
744
  decoder_checkpoints: "source",
745
745
  pox4_calls: "source",
746
746
  pox5_events: "source",
747
+ pox5_cycles: "source",
748
+ pox5_cycle_signers: "source",
747
749
  burn_block_rewards: "source",
748
750
  burn_block_reward_slots: "source",
749
751
  sbtc_events: "source",
@@ -955,6 +957,13 @@ async function closeDb() {
955
957
  }
956
958
  pools.clear();
957
959
  }
960
+ var DEFAULT_CLOSE_DB_TIMEOUT_MS = 30000;
961
+ async function closeDbOrTimeout(timeoutMs = DEFAULT_CLOSE_DB_TIMEOUT_MS, closeFn = closeDb) {
962
+ await Promise.race([
963
+ closeFn(),
964
+ new Promise((resolve) => setTimeout(resolve, timeoutMs))
965
+ ]);
966
+ }
958
967
  export {
959
968
  SOURCE_READ_COLUMNS,
960
969
  SOURCE_READ_PKS,
@@ -963,6 +972,7 @@ export {
963
972
  applicationDatabaseUrl,
964
973
  assertDbSplit,
965
974
  closeDb,
975
+ closeDbOrTimeout,
966
976
  describeDbUrl,
967
977
  getDb,
968
978
  getDbSplitStatus,
@@ -981,5 +991,5 @@ export {
981
991
  sql2 as sql
982
992
  };
983
993
 
984
- //# debugId=AD548AB47C78322F64756E2164756E21
994
+ //# debugId=DDB2C25F2D54E63664756E2164756E21
985
995
  //# sourceMappingURL=index.js.map