Skip to content

bug(feed-debug): per-session maps are resurrected by an append queued before forget #1207

Description

@Juliusolsson05

Found by the #1111 review (2026-09-25), deferred from that PR as a follow-up because it predates it.

Problem

src/main/storage/feedDebugLog.ts keeps per-session maps: lastWrittenFeedDebugId, feedDebugCapState, and since #1111 lastWrittenFeedDebugEpoch. forgetFeedDebugSession deletes them synchronously. But an append that was queued before the forget and has not started yet runs afterwards and writes the entries back. Queue settlement only reaps feedDebugWriteQueues, so nothing removes them again.

Reproduction (reviewer's probe): for 100 session ids, queue one real append, call forgetFeedDebugSession immediately, and await the writes. The epoch map keeps 100 dead entries. The id and cap maps have the same ordering problem.

Cost: a few numbers per closed session for the life of the process. It is small, but it grows without bound.

Fix direction

Give each session a forget generation: capture it when the append is queued, and skip every map write (or delete again at the end of the continuation) if it changed. Cover all three maps, and test with the real queue ordering, not a mock.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions