Skip to content

[copilot-finds] Improve: Dead _failedTasks field in CompositeTask and dead async-pageable.ts file #217

@github-actions

Description

@github-actions

Problem

Two instances of dead code exist in the core SDK:

1. _failedTasks field in CompositeTask (src/task/composite-task.ts, lines 12, 19)

The _failedTasks field is declared and initialized to 0 in the constructor, but never incremented or read by any code in the entire codebase. Neither WhenAllTask.onChildCompleted() nor WhenAnyTask.onChildCompleted() ever modifies this counter. The field misleadingly suggests that failed tasks are tracked separately from _completedTasks, but they are not.

Additionally, a stale comment in WhenAllTask (line 14) references _failedTasks as something that should not be re-initialized, but since the field is unused, the comment is misleading.

2. Dead src/utils/async-pageable.ts file (91 lines)

This file contains a complete AsyncPageable class with Page interface and PageFetcher type that is never imported by any file in the entire codebase. The actual pagination implementation lives in src/orchestration/page.ts (which is exported from index.ts and used by client.ts). The dead file creates confusion for developers navigating the codebase.

Root Cause

The _failedTasks field was likely planned as a counter for failed child tasks but was never wired into the WhenAllTask or WhenAnyTask completion logic. The async-pageable.ts file appears to be an earlier implementation that was superseded by page.ts but never cleaned up.

Proposed Fix

  1. Remove the _failedTasks field from CompositeTask
  2. Update the stale comment in WhenAllTask that references _failedTasks
  3. Delete the dead async-pageable.ts file
  4. Add unit tests that explicitly verify the _completedTasks counter correctly counts both successful and failed child completions (documenting the intended behavior)

Impact

Low severity. This is dead code cleanup that reduces maintenance burden and prevents confusion. No behavioral change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    copilot-findsFindings from daily automated code review agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions