Consume durable history from topic beginning
Some checks failed
deploy / deploy (push) Failing after 27s

Proof: npm test; node --test test/history-writer-static.test.mjs test/kafka-topics.test.mjs test/environment-status-history.test.mjs; node --check src/apps/history-writer.mjs.

Assumptions: Durable history consumers are idempotent by event_id, so from-beginning subscription is safe when a topic has no committed group offset.

Still fake: This protects durable event capture for repo-owned Kafka topics; it does not backfill events that were never published to Kafka.
This commit is contained in:
philipp 2026-04-17 14:41:22 +02:00
parent eb81f892e2
commit 8507403b0f
2 changed files with 11 additions and 1 deletions

View file

@ -106,7 +106,7 @@ const intentRequestOutcomeTopics = new Set([
]); ]);
for (const topic of topics) { for (const topic of topics) {
await consumer.subscribe({ topic, fromBeginning: false }); await consumer.subscribe({ topic, fromBeginning: true });
} }
const state = { const state = {

View file

@ -0,0 +1,10 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const source = readFileSync(new URL('../src/apps/history-writer.mjs', import.meta.url), 'utf8');
test('history writer consumes from beginning so first events on newly-created topics are durable', () => {
assert.match(source, /consumer\.subscribe\(\{ topic, fromBeginning: true \}\)/);
assert.doesNotMatch(source, /consumer\.subscribe\(\{ topic, fromBeginning: false \}\)/);
});