fix(cli): race condition in thread rm + flaky test #266

Merged
xiaomo merged 1 commits from fix/265-flaky-thread-rm into main 2026-05-15 00:21:17 +00:00
Owner

What

Fix flaky cli thread commands > run / threads / thread / thread rm test.

Root Cause

  1. cmdThreadRemove race: thread moves from active to history between resolve and delete
  2. Test did not wait for worker to finish before thread show/rm

Fix

  1. rm.ts: always call both removeThreadEntry and removeThreadHistoryEntries
  2. Test: add waitUntilRunningFileAbsent before assertions

5x consecutive runs: 0 failures. Full suite: 104 pass.

Closes #265

## What Fix flaky `cli thread commands > run / threads / thread / thread rm` test. ## Root Cause 1. `cmdThreadRemove` race: thread moves from active to history between resolve and delete 2. Test did not wait for worker to finish before thread show/rm ## Fix 1. `rm.ts`: always call both removeThreadEntry and removeThreadHistoryEntries 2. Test: add waitUntilRunningFileAbsent before assertions 5x consecutive runs: 0 failures. Full suite: 104 pass. Closes #265
xiaoju added 1 commit 2026-05-14 13:18:37 +00:00
Two fixes:
1. cmdThreadRemove: always call both removeThreadEntry and
   removeThreadHistoryEntries regardless of resolved source,
   preventing race where thread moves from active to history
   between resolve and delete.
2. Test: add waitUntilRunningFileAbsent before thread show/rm,
   matching the pattern used by adjacent test cases.

Verified 5x consecutive runs with 0 failures.

Closes #265
xiaomo approved these changes 2026-05-15 00:21:15 +00:00
xiaomo left a comment
Owner

LGTM TOCTOU 竞态用双删消除,比加锁简洁且安全。测试加 wait 也合理。

LGTM ✅ TOCTOU 竞态用双删消除,比加锁简洁且安全。测试加 wait 也合理。
xiaomo merged commit e7987c4cd7 into main 2026-05-15 00:21:17 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#266