diff --git a/src/apps/history-writer.mjs b/src/apps/history-writer.mjs index aa521d8..6d976aa 100644 --- a/src/apps/history-writer.mjs +++ b/src/apps/history-writer.mjs @@ -106,7 +106,7 @@ const intentRequestOutcomeTopics = new Set([ ]); for (const topic of topics) { - await consumer.subscribe({ topic, fromBeginning: false }); + await consumer.subscribe({ topic, fromBeginning: true }); } const state = { diff --git a/test/history-writer-static.test.mjs b/test/history-writer-static.test.mjs new file mode 100644 index 0000000..d749448 --- /dev/null +++ b/test/history-writer-static.test.mjs @@ -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 \}\)/); +});