Skip to content

[react-compiler-healthcheck] Add verbose failed-component reporting#515

Closed
everettbu wants to merge 1 commit into
mainfrom
chore/issue-35772-healthcheck-verbose
Closed

[react-compiler-healthcheck] Add verbose failed-component reporting#515
everettbu wants to merge 1 commit into
mainfrom
chore/issue-35772-healthcheck-verbose

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of facebook/react#35782
Original author: Arktomson


Summary

This PR adds a --verbose flag to react-compiler-healthcheck so failed component compilation details are printed only when requested.

  • Added a --verbose boolean CLI option in react-compiler-healthcheck.
  • Kept default behavior unchanged (the existing summary line is still the default output).
  • In verbose mode, failures are printed from both ActionableFailures and OtherFailures, including:
    • file path
    • location (when available)
    • reason/message
  • Sorted verbose failure output deterministically for stable/debuggable output.

Fixes #35772

How did you test this change?

I verified both build success and runtime CLI behavior in default and verbose modes.

cd compiler
yarn workspace react-compiler-healthcheck build
yarn workspace react-compiler-healthcheck test
# default mode (summary-only)
node ./packages/react-compiler-healthcheck/dist/index.js --src "../.sisyphus/tmp/healthcheck-failure-sample.tsx"

# verbose mode (includes failure details)
node ./packages/react-compiler-healthcheck/dist/index.js --src "../.sisyphus/tmp/healthcheck-failure-sample.tsx" --verbose

Observed results:

  • Build succeeded.
  • Default mode kept summary-only behavior (no detailed failure list).
  • Verbose mode printed detailed failure entries with file/location/reason.
  • For a failing sample, output included a concrete [ActionableFailure] ... line with source location and compiler reason.

@greptile-apps

greptile-apps Bot commented Feb 14, 2026

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

This PR adds a --verbose CLI flag to react-compiler-healthcheck that prints detailed per-failure information (file path, source location, and reason) when enabled. The default summary-only behavior is preserved.

  • Adds --verbose boolean option to the yargs CLI in index.ts and passes it to reactCompilerCheck.report().
  • Introduces SuccessEvent and FailureEvent type aliases using Extract on a refined discriminated union of LoggerEvent, improving type safety throughout.
  • Refactors isActionableDiagnostic to use the current ErrorSeverity.Error value instead of the legacy enum variants (InvalidReact, InvalidJS, etc.), aligning with upstream changes to the compiler's error severity model.
  • Adds formatLoc, getFailureReason, and getVerboseFailures helpers to format and sort failure entries deterministically for stable output.
  • Adds a default case to the logger's switch statement for exhaustiveness.

Confidence Score: 4/5

  • This PR is safe to merge — it adds an additive, opt-in verbose mode without changing default behavior.
  • The changes are well-structured and additive. The type refactoring is sound and aligns with upstream compiler changes. The verbose output logic is correct but has a minor inconsistency with the summary's deduplicated counts. No breaking changes to the default behavior.
  • compiler/packages/react-compiler-healthcheck/src/checks/reactCompiler.ts — verify the verbose failure count vs. deduplicated summary count is acceptable UX.

Important Files Changed

Filename Overview
compiler/packages/react-compiler-healthcheck/src/checks/reactCompiler.ts Adds verbose failure reporting with proper type narrowing, deterministic sorting, and formatted output. Refactors LoggerEvent to a discriminated union and updates isActionableDiagnostic to match the current ErrorSeverity enum. Minor concern: verbose output is not deduplicated like the summary count.
compiler/packages/react-compiler-healthcheck/src/index.ts Adds --verbose boolean CLI option via yargs and passes it through to reactCompilerCheck.report(). Clean, minimal change.

Last reviewed commit: d62ecc4

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +232 to +233
const verboseFailures = getVerboseFailures();
if (verboseFailures.length === 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verbose count may not match summary count

The summary line uses countUniqueLocInEvents() to deduplicate failures by filename + location, but getVerboseFailures() returns every raw event without deduplication. When multiple compiler errors fire for the same function (e.g. multiple rule violations in the same pass, as noted in the comment on countUniqueLocInEvents), verbose mode will list more entries than the summary's failed-component count implies. This could confuse users who see "compiled 8 out of 10 components" (2 failures) but then a verbose list of 5 entries.

Consider either deduplicating verbose output to match the summary count, or adding a note in the verbose header explaining that multiple failures may map to the same component.

Prompt To Fix With AI
This is a comment left during a code review.
Path: compiler/packages/react-compiler-healthcheck/src/checks/reactCompiler.ts
Line: 232:233

Comment:
**Verbose count may not match summary count**

The summary line uses `countUniqueLocInEvents()` to deduplicate failures by filename + location, but `getVerboseFailures()` returns every raw event without deduplication. When multiple compiler errors fire for the same function (e.g. multiple rule violations in the same pass, as noted in the comment on `countUniqueLocInEvents`), verbose mode will list more entries than the summary's failed-component count implies. This could confuse users who see "compiled 8 out of 10 components" (2 failures) but then a verbose list of 5 entries.

Consider either deduplicating verbose output to match the summary count, or adding a note in the verbose header explaining that multiple failures may map to the same component.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +149 to +166
function getFailureReason(event: FailureEvent): string {
switch (event.kind) {
case 'CompileError': {
const description = event.detail.description;
if (description == null || description.length === 0) {
return event.detail.reason;
}
return `${event.detail.reason}: ${description}`;
}
case 'CompileDiagnostic': {
if (
event.detail.description == null ||
event.detail.description.length === 0
) {
return event.detail.reason;
}
return `${event.detail.reason}: ${event.detail.description}`;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate logic in CompileError and CompileDiagnostic branches

The CompileError and CompileDiagnostic cases have identical logic for extracting the failure reason. Consider consolidating them:

Suggested change
function getFailureReason(event: FailureEvent): string {
switch (event.kind) {
case 'CompileError': {
const description = event.detail.description;
if (description == null || description.length === 0) {
return event.detail.reason;
}
return `${event.detail.reason}: ${description}`;
}
case 'CompileDiagnostic': {
if (
event.detail.description == null ||
event.detail.description.length === 0
) {
return event.detail.reason;
}
return `${event.detail.reason}: ${event.detail.description}`;
}
function getFailureReason(event: FailureEvent): string {
switch (event.kind) {
case 'CompileError':
case 'CompileDiagnostic': {
if (
event.detail.description == null ||
event.detail.description.length === 0
) {
return event.detail.reason;
}
return `${event.detail.reason}: ${event.detail.description}`;
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: compiler/packages/react-compiler-healthcheck/src/checks/reactCompiler.ts
Line: 149:166

Comment:
**Duplicate logic in `CompileError` and `CompileDiagnostic` branches**

The `CompileError` and `CompileDiagnostic` cases have identical logic for extracting the failure reason. Consider consolidating them:

```suggestion
function getFailureReason(event: FailureEvent): string {
  switch (event.kind) {
    case 'CompileError':
    case 'CompileDiagnostic': {
      if (
        event.detail.description == null ||
        event.detail.description.length === 0
      ) {
        return event.detail.reason;
      }
      return `${event.detail.reason}: ${event.detail.description}`;
    }
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

@everettbu

Copy link
Copy Markdown
Author

Upstream PR was closed or merged. Code is synced via branch mirror.

@everettbu everettbu closed this Feb 15, 2026
@everettbu
everettbu deleted the chore/issue-35772-healthcheck-verbose branch February 15, 2026 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants