Skip to content

test: fix TestHarvestTypedRecipients flake - #35

Merged
sspaeti merged 2 commits into
ssp-data:mainfrom
farangkao:fix/test-harvest-flake
Oct 18, 2026
Merged

sspaeti merged 2 commits into
ssp-data:mainfrom
farangkao:fix/test-harvest-flake

Conversation

@farangkao

Copy link
Copy Markdown
Contributor

This is a small fix for compose_test.go which was bumping up while i developed a new Feature 'imap message keywords', which i will create a seperate PR ,since this is an unrelated issue.

harvestTypedRecipients persists the contacts cache asynchronously (safeGo → SaveIfDirty). t.TempDir's cleanup can race that goroutine and fail the test with:

unlinkat … directory not empty

under repeated runs (-count / -race) — it only passed at -count=1 by luck of timing.

Fix: poll for the cache file to land on disk before the test ends (2 ms interval, 2 s deadline). Test-only change, pre-existing on main; surfaced while stress-testing the keyword-tags feature's identical write-through pattern.

Verified: intermittent failure with -count=20 before, stable after (-count=30, and -race -count=10).

harvestTypedRecipients persists the contacts cache asynchronously
(safeGo → SaveIfDirty). t.TempDir's cleanup can race that goroutine and
fail the test with:

    unlinkat … directory not empty

under repeated runs (-count / -race) — it only passed at -count=1 by
luck of timing.

Fix: poll for the cache file to land on disk before the test ends
(2 ms interval, 2 s deadline). Test-only change, pre-existing on main;
surfaced while stress-testing the keyword-tags feature's identical
write-through pattern.

Verified: intermittent failure with -count=20 before, stable after
(-count=30, and -race -count=10).
Same race class as TestHarvestTypedRecipients: applySenderRules persists
merges.toml via safeGo(store.Save) and t.TempDir cleanup can race that
goroutine ("unlinkat ... directory not empty"), flaky under -count and
on slow CI disks. Pre-existing on main — reproduced at the branch point
with -count=300.

Extract the poll-until-saved loop into a shared waitForFile helper and
use it from both tests.
@sspaeti
sspaeti merged commit 6f6cee4 into ssp-data:main Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants