rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] Add --show-existing-failure-logs parameter to skip execution and replay failure logs

Open Copilot opened this issue 2 months ago • 2 comments

Summary

Fixes the workflow inefficiency when performing sweeping monorepo changes (e.g., TypeScript upgrades) where developers lose track of which projects failed after fixing individual failures. Adds --show-existing-failure-logs parameter that replays error logs from previous runs without re-executing operations.

Fixes microsoft/rushstack#5450

Details

Implementation:

  • PhasedScriptAction: Added --show-existing-failure-logs flag parameter, incompatible with --watch
  • ShowExistingFailureLogsPlugin: New plugin that:
    • Checks for .rush/temp/operation/<phase>/error.log files
    • Returns OperationStatus.Failure if error log exists (replays via OperationMetadataManager.tryRestoreAsync)
    • Returns OperationStatus.Skipped if no error log (silences operation)
    • Applied before cache/skip plugins to ensure precedence
  • Build cache and legacy skip detection bypassed when flag active
  • Changelog: Added change file for @microsoft/rush documenting the new feature as a minor version change

Design choice: Returns terminal status from beforeExecuteOperation hook to prevent runner execution while preserving full operation graph traversal for dependencies.

Performance: Near-instant execution (0.00s per operation) - only reads existing files, no computation or network I/O.

How it was tested

Unit tests: Added comprehensive tests for ShowExistingFailureLogsPlugin covering both error log presence/absence scenarios.

Manual validation:

  1. Introduced TypeScript error in @microsoft/rush-lib, ran rush build --only @microsoft/rush-lib to generate error log
  2. Fixed error, ran rush build --show-existing-failure-logs --only @microsoft/rush-lib
  3. Verified: Operation completed in 0.00s, error log replayed exactly, no actual execution occurred
  4. Tested with --to selection: Confirmed operations without error logs were silenced (Skipped status)

Impacted documentation

  • Website docs may need update for phased command parameters: https://rushjs.io/pages/commands/rush_build/
  • Consider adding example to "Selecting subsets of projects" article

Example usage:

# Typical workflow during TypeScript upgrade
rush build                    # See multiple failures
rush build --to failing-pkg   # Fix one package
rush build --show-existing-failure-logs  # Review remaining failures without re-running
Original prompt

This section details on the original issue you should resolve

<issue_title>[rush] Add a parameter to PhasedScriptAction that skips execution and just dumps any existing failure logs</issue_title> <issue_description>## Summary When performing sweeping changes to a monorepo, for example upgrading TypeScript, one will often find themselves in the following loop:

  1. Run a broad rush build or rush test command to find issues
  2. Encounter several projects with issues
  3. Drill into a single project's failure log and work through the issues
  4. Recompile the failed project and see if any new issues show up
  5. Once the focused project is fixed, go back to (1) because all record of which other projects failed is hard to come by

It would be useful to be able to run a command like rush test --show-existing-failure-logs that would simply build the graph, look for the error log files, and for any operations where they exist, replay the log in the same manner as for a build cache hit. All operations that did not have existing failures would be silenced.

Additional use cases: AI agents could run rush build --to x, ignore the output (other than exit code), then run rush build --to x --show-existing-failure-logs to inject only the relevant information into the context.</issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes microsoft/rushstack#5450

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Nov 18 '25 22:11 Copilot

@copilot - this change needs a changelog entry.

iclanton avatar Nov 19 '25 22:11 iclanton

@copilot - this change needs a changelog entry.

Added changelog entry in commit 735ca53.

Copilot avatar Nov 19 '25 22:11 Copilot