Skip to content

Ratchet React Compiler panicThreshold in non-prod builds: critical_errors, then all_errors #31507

Description

@MajorLift

Performance audit finding · Severity: Medium (tooling/ratchet) · Effort: Medium, then ongoing · Fix risk: Simple (non-prod builds only) · Test safety net: N/A (build gate)
Owner: @MetaMask/mobile-platform (suggested)
File: babel.config.js:67
Depends on: #31500 (logger triage — provides the actionable-error list this ratchet burns down)

What is this about?

panicThreshold controls when a React Compiler diagnostic fails the build instead of silently skipping the file. Mobile currently runs the implicit default ('none'): every diagnostic is a silent skip, so compiler coverage can regress without anyone noticing. The ratchet makes a non-production build progressively intolerant:

Setting Build fails on Use
'none' (current/default) never — failed files silently skipped production, permanently
'critical_errors' compiler-internal invariant violations CI/debug gate, first target
'all_errors' every diagnostic incl. unsupported syntax CI/debug gate, end state

The extension tracks the same ladder as MetaMask-planning#6552 (enable critical_errors, fix violations) and #6553 (all_errors); its enablement-run split (metamask-extension#38007: 31 actionable errors vs 7,024 unsupported of 7,308 files) shows the actionable set a ratchet has to clear is small once the Todo category is excluded.

Scenario

N/A — build tooling.

Design

N/A.

Technical Details

  1. Add an env-gated Babel config path (or CI job) that sets panicThreshold: 'critical_errors' in the 'react-compiler' plugin options for non-production builds. Production stays 'none' permanently — one un-compilable file must never block a release for an optional optimization.
  2. Fix the actionable (non-Todo) errors surfaced by the Collect React Compiler coverage stats and triage actionable vs unsupported-syntax errors #31500 logger until the critical_errors gate passes; promote the gate to required CI.
  3. Repeat toward 'all_errors'. What remains after that is the unsupported (Todo) set, re-diffed on compiler upgrades — Todos that newly compile are free wins, new errors are regressions the gate now catches.

Threat Modeling Framework

N/A — non-production build gate; no runtime change.

Acceptance Criteria

  • Non-prod build passes at panicThreshold: 'critical_errors' and the gate runs in CI.
  • Follow-up ratchet to 'all_errors' tracked, with the remaining actionable-error count trending to zero.
  • Production builds verified unaffected ('none').

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Sev3area-performanceIssues relating to slowness of app, cpu usage, and/or blank screens.ta-triaged

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    To be fixed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions