test(agent-core-v2): dispose task fixtures before deleting their session dir - #216
Conversation
…ion dir Five task-manager cases created a temp session dir and an agent context, then deleted the dir in their finally block without disposing the context. The context kept writing session state into that dir while the delete walked it, which failed the run with ENOTEMPTY on a loaded CI machine. Dispose every context first, and let fs.rm retry the delete, which is what its maxRetries option exists for.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe test suite now disposes supplied agent contexts before removing temporary session directories. Session persistence tests retain contexts, and the persistence race test uses separate writer and reader fixtures. ChangesTask manager test cleanup
Estimated code review effort: 1 (Trivial) | ~3 minutes Merge Risk: ⚪ Minimal · up to This localized test-only change disposes agent contexts before removing their temporary session directories, preventing teardown races and leaked test resources. No actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
Full details: Description checkExplanation The description clearly explains the problem, implementation, verification, and lack of production changes. However, it states that no issue exists while marking the related-issue checklist item complete, and it does not provide the issue link required by the template.
Comment |
commit: |
Related Issue
No issue. Found when a CI shard failed on an unrelated PR with
ENOTEMPTY: directory not empty, rmdir '/tmp/pythinker-bg-limit-agent-*/sessions/test-workspace/test-session'.Problem
Five
AgentTaskServicecases create a temporary session directory and an agent context over it, then delete the directory in theirfinallyblock. None of them disposed the context first, so the context was still writing session state into that directory while the delete walked it. On a loaded CI machine the two race and the run fails withENOTEMPTY. The tests also leaked six agent contexts per run.One case already worked around a symptom of this by awaiting
ISessionMetadata.ready; the other four had nothing.What changed
cleanupSessionDir(sessionDir, ...contexts)test helper: disposes every context, then removes the directory withfs.rm's ownmaxRetries/retryDelay— the documented remedy forENOTEMPTY/EBUSY/EPERMfrom a concurrent writer.tryand clean up through the helper. No production code changes; no changeset, since nothing user-visible changes.Verification
test/agent/task/taskManager.test.ts— 48 passed, 3 consecutive runspnpm --filter @pymodel/agent-core-v2 exec vitest run— 347 files, 5,723 tests passedtypecheck,tsgo,check-no-comments, oxlint — exit 0Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.Summary by CodeRabbit