发布

  • fix(core): show flaky-task count in run summary (#35491)

    frostbyte_neo 发布于 2026-04-30 21:32:32 +00:00

    Current Behavior

    When Nx's task-history life cycle detects more than one flaky task, the
    summary header renders with two consecutive spaces and no number in
    place of the count, e.g.:

    > NX  Nx detected  flaky tasks
    
      myproject:test
      otherproject:e2e
    

    The singular case (one flaky task) renders correctly as Nx detected a flaky task.

    Expected Behavior

    > NX  Nx detected 2 flaky tasks
    
      myproject:test
      otherproject:e2e
    

    Root Cause

    Both task-history-life-cycle.ts and the legacy
    task-history-life-cycle-old.ts had:

    title: `Nx detected ${
      this.flakyTasks.length === 1 ? 'a flaky task' : ' flaky tasks'
    }`,
    

    The plural branch is a literal ' flaky tasks' string with a leading
    space and no count interpolation — so the template renders Nx detected + ' flaky tasks' = Nx detected flaky tasks (two spaces,
    no number).

    Fix

    Replace the plural literal with \${this.flakyTasks.length} flaky
    tasks`so the count appears between the leading space and the wordflaky`. Singular wording is unchanged.

    title: \`Nx detected \${
      this.flakyTasks.length === 1
        ? 'a flaky task'
        : \`\${this.flakyTasks.length} flaky tasks\`
    }\`,
    

    Same fix applied symmetrically in both life-cycle files.

    Tests

    No existing unit test covers printFlakyTasksMessage()'s formatted
    output (the surrounding life cycles don't have a *.spec.ts). Adding
    one would require mocking the task-history daemon channel and life-cycle
    hooks — out of scope for a one-line formatting fix. The change is small
    enough to verify by inspection of the diff.

    Related Issue(s)

    (reported internally; no public issue)

    下载附件