Skip to content

Commit 6163309

Browse files
committed
[compiler] Remove tryRecord, add catch-all error handling, fix remaining throws
Remove `tryRecord()` from the compilation pipeline now that all passes record errors directly via `env.recordError()` / `env.recordErrors()`. A single catch-all try/catch in Program.ts provides the safety net for any pass that incorrectly throws instead of recording. Key changes: - Remove all ~64 `env.tryRecord()` wrappers in Pipeline.ts - Delete `tryRecord()` method from Environment.ts - Add `CompileUnexpectedThrow` logger event so thrown errors are detectable - Log `CompileUnexpectedThrow` in Program.ts catch-all for non-invariant throws - Fail snap tests on `CompileUnexpectedThrow` to surface pass bugs in dev - Convert throwTodo/throwDiagnostic calls in HIRBuilder (fbt, this), CodegenReactiveFunction (for-in/for-of), and BuildReactiveFunction to record errors or use invariants as appropriate - Remove try/catch from BuildHIR's lower() since inner throws are now recorded - CollectOptionalChainDependencies: return null instead of throwing on unsupported optional chain patterns (graceful optimization skip)
1 parent 39b5e7c commit 6163309

25 files changed

Lines changed: 340 additions & 410 deletions

compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ export type LoggerEvent =
254254
| CompileErrorEvent
255255
| CompileDiagnosticEvent
256256
| CompileSkipEvent
257+
| CompileUnexpectedThrowEvent
257258
| PipelineErrorEvent
258259
| TimingEvent
259260
| AutoDepsDecorationsEvent
@@ -290,6 +291,11 @@ export type PipelineErrorEvent = {
290291
fnLoc: t.SourceLocation | null;
291292
data: string;
292293
};
294+
export type CompileUnexpectedThrowEvent = {
295+
kind: 'CompileUnexpectedThrow';
296+
fnLoc: t.SourceLocation | null;
297+
data: string;
298+
};
293299
export type TimingEvent = {
294300
kind: 'Timing';
295301
measurement: PerformanceMeasure;

0 commit comments

Comments
 (0)