expose durable cursor age so relay replay exhaustion is visible
48 unmodified lines49505152535455565758596068 unmodified lines129130131132133134135136137138139140141142386 unmodified linesExpand all48 unmodified lineslet initialBackfillScanned = 0let lastInitialBackfillCompletedAt: number | undefinedlet initialBackfillRetryAttempt = 0
function cursorAgeSeconds(value: number | undefined): number | undefined { return value === undefined ? undefined : boundedNumber(Math.floor(value / 1000))}
function boundedNumber(value: unknown): number { return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? Math.min(value, 1_000_000) : 0}
68 unmodified lines started: intake.started, queued: Math.min(intake.queued, config.intakeQueueMax), directConnected: intake.directConnected, backlinkConnected: intake.backlinkConnected, // Relay replay is finite: a cursor age approaching it loses events. cursorAgeSeconds: { direct: cursorAgeSeconds(intake.cursorAgeMs.direct), backlink: cursorAgeSeconds(intake.cursorAgeMs.backlink), registry: cursorAgeSeconds(intake.cursorAgeMs.registry), }, admissionLimits: intake.admissionLimits, streamFailures: intake.streamFailures, }, }386 unmodified linesExpand all1351 unmodified linesExpand all135213531354135513561357135813591360136113621363136482 unmodified lines1351 unmodified linesExpand all registryConnected, directProgressing, backlinkProgressing, registryProgressing, cursorAgeMs: { direct: directJetstream?.cursorAgeMs, backlink: backlinkJetstream?.cursorAgeMs, registry: registryJetstream?.cursorAgeMs, }, started: firehoseStarted, paused: intakePaused, queued: (directJetstream?.queued ?? 0) + (backlinkJetstream?.queued ?? 0) + (registryJetstream?.queued ?? 0), activeRecordKeys: recordExecutor.size,82 unmodified lines533 unmodified linesExpand all534535536537538539540541542543544545546547548549550551100 unmodified lines533 unmodified linesExpand all get cursor(): number | undefined { return this.lastAckedCursor }
/** * How far the durable cursor trails the present, in milliseconds. A relay * only retains a few days of replay, so an age approaching that window means * events are about to be lost silently rather than merely late. */ get cursorAgeMs(): number | undefined { if (this.lastAckedCursor === undefined) return undefined return Math.max(0, Date.now() - Math.floor(this.lastAckedCursor / 1000)) }
get queued(): number { return this.queue.length }
100 unmodified lines