Repository navigation
Conversation
|
The build for this commit did not complete, so there is no size report. See the workflow run for details. Generated by sizebot against a0b0880 |
|
Two reads in the same family are left unguarded, and both are on the exact path this PR targets (a Scheduler task that fires after the environment is gone):
Guarding only the three functions in this diff therefore leaves the crash reachable through the update path. Also: this was re-reported as #38161 (it points at the unguarded reads on Separately, and unrelated to the fix: the diff also rewrites |
| // at runtime. We should instead inject the version number as part of the build | ||
| // process, and use the ReactVersions.js module as the single source of truth. | ||
| export default '19.3.0'; | ||
| export default '19.3.0-canary-b685b40d-20260724'; |
There was a problem hiding this comment.
You might want to revert this file so that you will not have merge conflicts
Summary
Fixes #37100.
The DEV-only Performance Tracks instrumentation added in 19.2.0 reads
window.eventunconditionally intrackSchedulerEvent(),resolveEventType(), andresolveEventTimeStamp().trackSchedulerEvent()runs at the entry of Scheduler-driven tasks (performWorkOnRootViaSchedulerTask,processRootScheduleInImmediateTask, and the passive-effects flush scheduled bycommitRoot). These tasks live on deferredsetImmediateticks and can legitimately fire after a per-test-file DOM environment (jsdom / happy-dom under vitest or jest) has been torn down. When that happens the task throwsReferenceError: window is not definedbefore doing any work, which fails entire CI suites with an unhandled error attributed to the next, innocent test file.This guards the three reads with
typeof window !== 'undefined', matching the bundle's existing convention forwindowaccesses that may run outside a browser DOM (e.g.canUseDOM, thewindow.ErrorEventdetection in the error-reporting path). Whenwindowis gone the attribution resolves toundefined, i.e. "no event", which is accurate.shouldAttemptEagerTransition()andresolveUpdatePriority()are left untouched: they only run while an update is being dispatched, sowindowis alive by construction there.How did you test this change?
ReactDOMWindowTeardown-test.js, node environment + manually constructed JSDOM mirroring the issue's repro). It fails onmainwithReferenceError: window is not definedfromperformWorkOnRootViaSchedulerTaskand passes with this change.yarn test ReactPerformanceTrack ReactDOMFiberAsync ReactDOMNativeEventHeuristic— all pass.yarn linc,yarn flow dom-node,yarn prettier— clean.react-dom@19.2.8it crashes as reported; against a locally builtNODE_DEVbundle with this change it printsdone, no crashand exits 0.