[BUG] tasks/.lock file never released on normal session exit
Resolved 💬 3 comments Opened Jan 31, 2026 by clthuang Closed Feb 4, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The ~/.claude/tasks/<session-id>/.lock file is never released, even when a session ends normally. This causes the lock to accumulate over time and can block future sessions that restore from backup.
Evidence from Debug Log
Session f95a8114-818e-4532-8659-24ee005472fb:
11:40:13.147 - First TaskCreate → .lock file created
11:40:13 to 11:40:21 - Multiple TaskCreate operations (9 total)
11:47:03.794 - Session ended NORMALLY with SessionEnd hook
Result: Lock file still exists after normal session termination.
$ ls -la ~/.claude/tasks/f95a8114-818e-4532-8659-24ee005472fb/
-rw-r--r-- 1 terry staff 0 31 Jan 19:40 .lock # Never released
-rw-r--r-- 1 terry staff 2 31 Jan 19:44 .highwatermark
Comparison with history.jsonl.lock
| Lock | Type | Released on normal exit? |
|------|------|-------------------------|
| history.jsonl.lock | Directory | ✅ Yes |
| tasks/<session>/.lock | File | ❌ No |
Impact
- Lock files accumulate with each session that uses tasks
- When restoring
~/.claudefrom backup, stale locks cause hangs - Users may not realize the tasks lock exists (only
history.jsonl.lockis documented)
What Should Happen?
The tasks/.lock file should be:
- Released when the session ends normally (SessionEnd hook)
- Released in a cleanup handler for SIGINT/SIGTERM
- Subject to stale lock detection (check if owning PID is alive)
Steps to Reproduce
- Start Claude Code
- Create tasks using TaskCreate tool
- Exit normally (Ctrl+D or
/exit) - Check:
ls ~/.claude/tasks/*/.lock - Result: Lock file still exists
Workaround
find ~/.claude/tasks -name ".lock" -delete
Related Issues
- #22166 - Stale
history.jsonl.lockcauses freeze (different lock, similar symptoms)
Environment
- OS: macOS (Darwin 25.2.0)
- Claude Code Version: 2.1.27
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗