Skip to content

fix(task): guard saveClineMessages against abandoned tasks to prevent race in abandonSubtask #1021

Open

Description

@edelauna

Problem

Fire-and-forget saveClineMessages() calls can execute updateTaskHistory() after abandonSubtask()'s atomicUpdatePair() has already cleared parentTaskId/rootTaskId, silently reattaching the severed parent-child link.

Root cause

saveClineMessages() is called without await in several places. If those in-flight calls resolve after abandonSubtask() completes, updateTaskHistory() writes back the now-stale parent/root IDs, effectively un-abandoning the subtask relationship.

Fix

Check this.abandoned before calling updateTaskHistory() in both the explicit abort save and any in-flight fire-and-forget saves. This is already implemented on the feature/local-usage-stats branch (commit 1d1eb915e) and should be extracted into its own PR.

Impact

Silent data corruption in subtask history — a subtask that was intentionally abandoned can reappear linked to its parent after the race resolves.

Activity

  1. added
    bug
    on Jul 25, 2026
  2. added a commit that references this issue on Sep 27, 2026
    561417d
  3. added a commit that references this issue on Nov 9, 2026
    b10779d
  4. added a commit that references this issue on Nov 28, 2026
    e6df210
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions