Skip to content

test(goal-loop): GoalLoopService tests leave persistence running after cleanup (ENOENT noise) #1341

Description

@Juliusolsson05

Expected

Each GoalLoopService.test.ts case finishes its own async work (fire-and-forget persist() / maybeContinue()) before afterEach removes its temp directory.

Actual

The tests leave async persistence running after they end. afterEach deletes the temp dir, and the late GoalLoopStore.write() then logs [goal-loop] persisting loop state failed: ENOENT … rename …goal-loop.json.<uuid>.tmp. Main CI run 36156560842 has 13 such warnings against 13 distinct temp dirs (12 rename, 1 open), all in the GoalLoopService worker.

Impact

Test hygiene, not user state: the errors are caught, and all the paths are test temp dirs. But the leftover work adds noise and can perturb fake-timer/I/O ordering in later cases in the same worker, which is the class of race behind #1314.

Where

src/main/goalLoop/GoalLoopService.test.ts (afterEach at the top) against GoalLoopService.ts void this.persist() / void this.maybeContinue().

Fix direction

Give the service a test-only drain (await in-flight continuations and persists), or stop the service before cleanup; do not swallow the log.

Found by review c of #1337 (issue #1314). P3.

🤖 Generated with Claude Code

Activity

  1. Juliusolsson05 commented on Sep 27, 2026

    @Juliusolsson05
    OwnerAuthor

    Also covers #1296 items 3 and 7 (moved here from PR #1353):

    • goalLoopTurnHooks.system.test.ts settles 20 ms before rm (ENOTEMPTY under load);
    • fixed 10–300 ms sleeps followed by 'not called' in GoalLoopService.test.ts (:64, :74, :205), goalLoop.system.test.ts:59 and goalLoopTurnHooks.system.test.ts (:101-106, :123) pass vacuously under load.

    All three share this root cause: persistence and continuation work outliving the test. A drain on the service (await in-flight continuations and persists) makes 'nothing happened' provable and cleanup safe, replacing the sleeps. Blocked on #1337, which is changing GoalLoopService.test.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions