Skip to content

[tests] Fix flaky flight tests - #35513

Merged
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values
Jan 18, 2026
Merged

[tests] Fix flaky flight tests#35513
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values

Conversation

@rickhanlonii

@rickhanloniirickhanlonii commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Flights tests are failing locally and in CI non-deterministically because we're not disabling async hooks after tests, and GC can clear WeakRefs non-deterministically.

This PR fixes the issue by adding an afterEach to disable installed hooks, and normalizing the value to value: {value: undefined}} when snapshotting.

Claude found the fix, here's the explanation:

Summary of Both Flaky Test Issues

Issue 1: ReactFlightDOMEdge-test.js - Cross-Test Async Hook Pollution

Root Cause:

  • When tests run with --runInBand, they execute sequentially in the same process
  • ReactFlightAsyncDebugInfo-test.js loads the Node server which creates async hooks via createHook().enable() to track async operations
  • ReactFlightDOMEdge-test.js loads the Edge server which uses a Noop debug config (no async hooks created) - The async hooks from the Node server persisted across tests because:
    • The Edge server doesn't create new hooks, so the cleanup code in setupTests.js never triggered
    • Old hooks kept firing their callbacks, calling performance.now() on the Edge test's mocks
    • This caused the Edge test's time values to be 232, 259, 260 instead of expected 12, 13, 14

The Fix: scripts/jest/setupTests.js

afterEach(() => {
if (installedHook) {
installedHook.disable();
installedHook = null;
}
});

This ensures async hooks are disabled after each test, preventing cross-test pollution.

Issue 2: ReactFlightAsyncDebugInfo-test.js - WeakRef Garbage Collection

Root Cause:

  • React's async debug info uses WeakRef to hold references to promises without preventing garbage collection
  • When serializing debug info, the code calls weakRef.deref() to get the promise
  • If GC has run: deref() returns undefined, and the server doesn't include the value field at all
  • If GC hasn't run: deref() returns the promise, and the server includes value: { value: undefined }
  • Since GC timing is non-deterministic (depends on memory pressure, CPU, etc.), tests would randomly pass or fail

The Fix: packages/internal-test-utils/debugInfo.js

// In normalizeIOInfo()
} else if ('value' in ioInfo) {
// If value exists but is undefined (WeakRef was GC'd)
copy.value = { value: undefined };
} else if (ioInfo.name && ioInfo.name !== 'rsc stream') {
// If value is completely missing (server didn't send it due to GC)
copy.value = { value: undefined };
}

This normalizes the output so snapshots always see a consistent structure regardless of GC timing.


★ Insight ─────────────────────────────────────
Two Patterns for Flaky Tests:

  1. State Leakage Between Tests: When tests run sequentially, global state (like async hooks, timers, or singletons) can leak. Solution: Clean up thoroughly in afterEach.
  2. Non-Deterministic System Behavior: When tests depend on unpredictable behavior (GC timing, network timing, file system operations), normalize the data in test utilities rather than trying to control the underlying system.
    ─────────────────────────────────────────────────

Both issues shared a common theme: non-deterministic behavior in sequential test execution. The first was about test isolation failure, the second was about normalizing inherently non-deterministic runtime behavior.

@rickhanloniirickhanlonii changed the title Fix flaky time values in ReactFlight-test.js[tests] Fix flaky time values in ReactFlight-test.jsJan 15, 2026
@github-actionsgithub-actionsBot added the React Core Team Opened by a member of the React Core Team label Jan 15, 2026
@react-sizebot

react-sizebot commented Jan 15, 2026

Copy link
Copy Markdown

Comparing: d87298a...e01bf9b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-stable/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js=608.48 kB608.03 kB+0.01%107.60 kB107.61 kB
oss-experimental/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
facebook-www/ReactDOM-prod.classic.js=693.87 kB693.38 kB+0.02%121.97 kB122.00 kB
facebook-www/ReactDOM-prod.modern.js=684.25 kB683.76 kB+0.02%120.37 kB120.40 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-experimental/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-experimental/react-art/cjs/react-art.production.js=358.82 kB357.47 kB=60.39 kB60.22 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js=1,262.88 kB1,257.62 kB=209.88 kB208.89 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js=1,262.87 kB1,257.62 kB=210.68 kB209.73 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js=1,246.33 kB1,241.07 kB=207.01 kB206.04 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js=685.36 kB681.67 kB=121.56 kB121.07 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js=862.57 kB857.88 kB=134.34 kB133.50 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
oss-experimental/react-dom/cjs/react-dom-profiling.profiling.js=750.23 kB745.88 kB=129.58 kB128.84 kB
oss-experimental/react-art/cjs/react-art.development.js=734.08 kB729.74 kB=115.50 kB114.68 kB
facebook-react-native/react/cjs/React-dev.js=52.93 kB52.61 kB=11.64 kB11.61 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js=491.86 kB488.70 kB=78.14 kB77.71 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js=568.03 kB564.15 kB=88.36 kB87.75 kB
facebook-www/React-profiling.classic.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-profiling.modern.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-prod.classic.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-www/React-prod.modern.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-react-native/react/cjs/React-profiling.js=19.96 kB19.66 kB=5.06 kB5.03 kB
oss-experimental/react/cjs/react.production.js=19.76 kB19.46 kB=4.95 kB4.92 kB
facebook-react-native/react/cjs/React-prod.js=19.53 kB19.23 kB=4.98 kB4.95 kB
oss-experimental/react/cjs/react.react-server.production.js=19.41 kB19.11 kB=5.03 kB5.00 kB
oss-stable/react/cjs/react.production.js=18.07 kB17.77 kB=4.62 kB4.59 kB
oss-stable-semver/react/cjs/react.production.js=18.04 kB17.74 kB=4.60 kB4.57 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Generated by 🚫 dangerJS against e01bf9b

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As far as I understand these tests do care about the debug info entries with the mocked time (introduced in #31716). For example, you want to assert that they are sequential and not overlapping, which is why there are also comments like Clamped to the start. So they are roughly asserting how this would lay out in the performance tracks. I've also never seen them flake. Under which circumstances did that happen to you?

@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I've seen CI fail quite a few times from this lately on my PRs, and on main.

For example, this commit from main failed from this in ReactFlightDOMEdge.

This test failed on my latest PR also from ReactFlightDOMEdge.

But aside from CI, I can basically repro locally any time I run yarn test, which makes it really annoying to test my changes before pushing.

@rickhanlonii

rickhanlonii commented Jan 18, 2026

Copy link
Copy Markdown
ContributorAuthor

The root cause seems to be that when those tests are run alongside other tests, the timing changes due to subtle delays in execution caused by the other test runs.

@rickhanlonii
rickhanloniiforce-pushed the fix-reactflight-test-flaky-time-values branch from a738e51 to e01bf9bCompareJanuary 18, 2026 19:17
@rickhanloniirickhanlonii changed the title [tests] Fix flaky time values in ReactFlight-test.js[tests] Fix flaky flight testsJan 18, 2026
@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I found the root cause, see the new description and fixes - none of the test snapshots need to change now.

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Makes sense!

@rickhanlonii
rickhanlonii merged commit 195fd22 into react:mainJan 18, 2026
234 checks passed
@rickhanlonii
rickhanlonii deleted the fix-reactflight-test-flaky-time-values branch January 18, 2026 20:36
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedReact Core TeamOpened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rickhanlonii@react-sizebot@unstubbable
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
[tests] Fix flaky flight tests by rickhanlonii · Pull Request #35513 · react/react · GitHub
Skip to content

[tests] Fix flaky flight tests - #35513

Merged
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values
Jan 18, 2026
Merged

[tests] Fix flaky flight tests#35513
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values

Conversation

@rickhanlonii

@rickhanloniirickhanlonii commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Flights tests are failing locally and in CI non-deterministically because we're not disabling async hooks after tests, and GC can clear WeakRefs non-deterministically.

This PR fixes the issue by adding an afterEach to disable installed hooks, and normalizing the value to value: {value: undefined}} when snapshotting.

Claude found the fix, here's the explanation:

Summary of Both Flaky Test Issues

Issue 1: ReactFlightDOMEdge-test.js - Cross-Test Async Hook Pollution

Root Cause:

  • When tests run with --runInBand, they execute sequentially in the same process
  • ReactFlightAsyncDebugInfo-test.js loads the Node server which creates async hooks via createHook().enable() to track async operations
  • ReactFlightDOMEdge-test.js loads the Edge server which uses a Noop debug config (no async hooks created) - The async hooks from the Node server persisted across tests because:
    • The Edge server doesn't create new hooks, so the cleanup code in setupTests.js never triggered
    • Old hooks kept firing their callbacks, calling performance.now() on the Edge test's mocks
    • This caused the Edge test's time values to be 232, 259, 260 instead of expected 12, 13, 14

The Fix: scripts/jest/setupTests.js

afterEach(() => {
if (installedHook) {
installedHook.disable();
installedHook = null;
}
});

This ensures async hooks are disabled after each test, preventing cross-test pollution.

Issue 2: ReactFlightAsyncDebugInfo-test.js - WeakRef Garbage Collection

Root Cause:

  • React's async debug info uses WeakRef to hold references to promises without preventing garbage collection
  • When serializing debug info, the code calls weakRef.deref() to get the promise
  • If GC has run: deref() returns undefined, and the server doesn't include the value field at all
  • If GC hasn't run: deref() returns the promise, and the server includes value: { value: undefined }
  • Since GC timing is non-deterministic (depends on memory pressure, CPU, etc.), tests would randomly pass or fail

The Fix: packages/internal-test-utils/debugInfo.js

// In normalizeIOInfo()
} else if ('value' in ioInfo) {
// If value exists but is undefined (WeakRef was GC'd)
copy.value = { value: undefined };
} else if (ioInfo.name && ioInfo.name !== 'rsc stream') {
// If value is completely missing (server didn't send it due to GC)
copy.value = { value: undefined };
}

This normalizes the output so snapshots always see a consistent structure regardless of GC timing.


★ Insight ─────────────────────────────────────
Two Patterns for Flaky Tests:

  1. State Leakage Between Tests: When tests run sequentially, global state (like async hooks, timers, or singletons) can leak. Solution: Clean up thoroughly in afterEach.
  2. Non-Deterministic System Behavior: When tests depend on unpredictable behavior (GC timing, network timing, file system operations), normalize the data in test utilities rather than trying to control the underlying system.
    ─────────────────────────────────────────────────

Both issues shared a common theme: non-deterministic behavior in sequential test execution. The first was about test isolation failure, the second was about normalizing inherently non-deterministic runtime behavior.

@rickhanloniirickhanlonii changed the title Fix flaky time values in ReactFlight-test.js[tests] Fix flaky time values in ReactFlight-test.jsJan 15, 2026
@github-actionsgithub-actionsBot added the React Core Team Opened by a member of the React Core Team label Jan 15, 2026
@react-sizebot

react-sizebot commented Jan 15, 2026

Copy link
Copy Markdown

Comparing: d87298a...e01bf9b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-stable/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js=608.48 kB608.03 kB+0.01%107.60 kB107.61 kB
oss-experimental/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
facebook-www/ReactDOM-prod.classic.js=693.87 kB693.38 kB+0.02%121.97 kB122.00 kB
facebook-www/ReactDOM-prod.modern.js=684.25 kB683.76 kB+0.02%120.37 kB120.40 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-experimental/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-experimental/react-art/cjs/react-art.production.js=358.82 kB357.47 kB=60.39 kB60.22 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js=1,262.88 kB1,257.62 kB=209.88 kB208.89 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js=1,262.87 kB1,257.62 kB=210.68 kB209.73 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js=1,246.33 kB1,241.07 kB=207.01 kB206.04 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js=685.36 kB681.67 kB=121.56 kB121.07 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js=862.57 kB857.88 kB=134.34 kB133.50 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
oss-experimental/react-dom/cjs/react-dom-profiling.profiling.js=750.23 kB745.88 kB=129.58 kB128.84 kB
oss-experimental/react-art/cjs/react-art.development.js=734.08 kB729.74 kB=115.50 kB114.68 kB
facebook-react-native/react/cjs/React-dev.js=52.93 kB52.61 kB=11.64 kB11.61 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js=491.86 kB488.70 kB=78.14 kB77.71 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js=568.03 kB564.15 kB=88.36 kB87.75 kB
facebook-www/React-profiling.classic.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-profiling.modern.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-prod.classic.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-www/React-prod.modern.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-react-native/react/cjs/React-profiling.js=19.96 kB19.66 kB=5.06 kB5.03 kB
oss-experimental/react/cjs/react.production.js=19.76 kB19.46 kB=4.95 kB4.92 kB
facebook-react-native/react/cjs/React-prod.js=19.53 kB19.23 kB=4.98 kB4.95 kB
oss-experimental/react/cjs/react.react-server.production.js=19.41 kB19.11 kB=5.03 kB5.00 kB
oss-stable/react/cjs/react.production.js=18.07 kB17.77 kB=4.62 kB4.59 kB
oss-stable-semver/react/cjs/react.production.js=18.04 kB17.74 kB=4.60 kB4.57 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Generated by 🚫 dangerJS against e01bf9b

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As far as I understand these tests do care about the debug info entries with the mocked time (introduced in #31716). For example, you want to assert that they are sequential and not overlapping, which is why there are also comments like Clamped to the start. So they are roughly asserting how this would lay out in the performance tracks. I've also never seen them flake. Under which circumstances did that happen to you?

@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I've seen CI fail quite a few times from this lately on my PRs, and on main.

For example, this commit from main failed from this in ReactFlightDOMEdge.

This test failed on my latest PR also from ReactFlightDOMEdge.

But aside from CI, I can basically repro locally any time I run yarn test, which makes it really annoying to test my changes before pushing.

@rickhanlonii

rickhanlonii commented Jan 18, 2026

Copy link
Copy Markdown
ContributorAuthor

The root cause seems to be that when those tests are run alongside other tests, the timing changes due to subtle delays in execution caused by the other test runs.

@rickhanlonii
rickhanloniiforce-pushed the fix-reactflight-test-flaky-time-values branch from a738e51 to e01bf9bCompareJanuary 18, 2026 19:17
@rickhanloniirickhanlonii changed the title [tests] Fix flaky time values in ReactFlight-test.js[tests] Fix flaky flight testsJan 18, 2026
@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I found the root cause, see the new description and fixes - none of the test snapshots need to change now.

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Makes sense!

@rickhanlonii
rickhanlonii merged commit 195fd22 into react:mainJan 18, 2026
234 checks passed
@rickhanlonii
rickhanlonii deleted the fix-reactflight-test-flaky-time-values branch January 18, 2026 20:36
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedReact Core TeamOpened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rickhanlonii@react-sizebot@unstubbable
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [tests] Fix flaky flight tests by rickhanlonii · Pull Request #35513 · react/react · GitHub
Skip to content

[tests] Fix flaky flight tests - #35513

Merged
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values
Jan 18, 2026
Merged

[tests] Fix flaky flight tests#35513
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values

Conversation

@rickhanlonii

@rickhanloniirickhanlonii commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Flights tests are failing locally and in CI non-deterministically because we're not disabling async hooks after tests, and GC can clear WeakRefs non-deterministically.

This PR fixes the issue by adding an afterEach to disable installed hooks, and normalizing the value to value: {value: undefined}} when snapshotting.

Claude found the fix, here's the explanation:

Summary of Both Flaky Test Issues

Issue 1: ReactFlightDOMEdge-test.js - Cross-Test Async Hook Pollution

Root Cause:

  • When tests run with --runInBand, they execute sequentially in the same process
  • ReactFlightAsyncDebugInfo-test.js loads the Node server which creates async hooks via createHook().enable() to track async operations
  • ReactFlightDOMEdge-test.js loads the Edge server which uses a Noop debug config (no async hooks created) - The async hooks from the Node server persisted across tests because:
    • The Edge server doesn't create new hooks, so the cleanup code in setupTests.js never triggered
    • Old hooks kept firing their callbacks, calling performance.now() on the Edge test's mocks
    • This caused the Edge test's time values to be 232, 259, 260 instead of expected 12, 13, 14

The Fix: scripts/jest/setupTests.js

afterEach(() => {
if (installedHook) {
installedHook.disable();
installedHook = null;
}
});

This ensures async hooks are disabled after each test, preventing cross-test pollution.

Issue 2: ReactFlightAsyncDebugInfo-test.js - WeakRef Garbage Collection

Root Cause:

  • React's async debug info uses WeakRef to hold references to promises without preventing garbage collection
  • When serializing debug info, the code calls weakRef.deref() to get the promise
  • If GC has run: deref() returns undefined, and the server doesn't include the value field at all
  • If GC hasn't run: deref() returns the promise, and the server includes value: { value: undefined }
  • Since GC timing is non-deterministic (depends on memory pressure, CPU, etc.), tests would randomly pass or fail

The Fix: packages/internal-test-utils/debugInfo.js

// In normalizeIOInfo()
} else if ('value' in ioInfo) {
// If value exists but is undefined (WeakRef was GC'd)
copy.value = { value: undefined };
} else if (ioInfo.name && ioInfo.name !== 'rsc stream') {
// If value is completely missing (server didn't send it due to GC)
copy.value = { value: undefined };
}

This normalizes the output so snapshots always see a consistent structure regardless of GC timing.


★ Insight ─────────────────────────────────────
Two Patterns for Flaky Tests:

  1. State Leakage Between Tests: When tests run sequentially, global state (like async hooks, timers, or singletons) can leak. Solution: Clean up thoroughly in afterEach.
  2. Non-Deterministic System Behavior: When tests depend on unpredictable behavior (GC timing, network timing, file system operations), normalize the data in test utilities rather than trying to control the underlying system.
    ─────────────────────────────────────────────────

Both issues shared a common theme: non-deterministic behavior in sequential test execution. The first was about test isolation failure, the second was about normalizing inherently non-deterministic runtime behavior.

@rickhanloniirickhanlonii changed the title Fix flaky time values in ReactFlight-test.js[tests] Fix flaky time values in ReactFlight-test.jsJan 15, 2026
@github-actionsgithub-actionsBot added the React Core Team Opened by a member of the React Core Team label Jan 15, 2026
@react-sizebot

react-sizebot commented Jan 15, 2026

Copy link
Copy Markdown

Comparing: d87298a...e01bf9b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-stable/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js=608.48 kB608.03 kB+0.01%107.60 kB107.61 kB
oss-experimental/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
facebook-www/ReactDOM-prod.classic.js=693.87 kB693.38 kB+0.02%121.97 kB122.00 kB
facebook-www/ReactDOM-prod.modern.js=684.25 kB683.76 kB+0.02%120.37 kB120.40 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-experimental/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-experimental/react-art/cjs/react-art.production.js=358.82 kB357.47 kB=60.39 kB60.22 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js=1,262.88 kB1,257.62 kB=209.88 kB208.89 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js=1,262.87 kB1,257.62 kB=210.68 kB209.73 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js=1,246.33 kB1,241.07 kB=207.01 kB206.04 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js=685.36 kB681.67 kB=121.56 kB121.07 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js=862.57 kB857.88 kB=134.34 kB133.50 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
oss-experimental/react-dom/cjs/react-dom-profiling.profiling.js=750.23 kB745.88 kB=129.58 kB128.84 kB
oss-experimental/react-art/cjs/react-art.development.js=734.08 kB729.74 kB=115.50 kB114.68 kB
facebook-react-native/react/cjs/React-dev.js=52.93 kB52.61 kB=11.64 kB11.61 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js=491.86 kB488.70 kB=78.14 kB77.71 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js=568.03 kB564.15 kB=88.36 kB87.75 kB
facebook-www/React-profiling.classic.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-profiling.modern.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-prod.classic.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-www/React-prod.modern.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-react-native/react/cjs/React-profiling.js=19.96 kB19.66 kB=5.06 kB5.03 kB
oss-experimental/react/cjs/react.production.js=19.76 kB19.46 kB=4.95 kB4.92 kB
facebook-react-native/react/cjs/React-prod.js=19.53 kB19.23 kB=4.98 kB4.95 kB
oss-experimental/react/cjs/react.react-server.production.js=19.41 kB19.11 kB=5.03 kB5.00 kB
oss-stable/react/cjs/react.production.js=18.07 kB17.77 kB=4.62 kB4.59 kB
oss-stable-semver/react/cjs/react.production.js=18.04 kB17.74 kB=4.60 kB4.57 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Generated by 🚫 dangerJS against e01bf9b

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As far as I understand these tests do care about the debug info entries with the mocked time (introduced in #31716). For example, you want to assert that they are sequential and not overlapping, which is why there are also comments like Clamped to the start. So they are roughly asserting how this would lay out in the performance tracks. I've also never seen them flake. Under which circumstances did that happen to you?

@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I've seen CI fail quite a few times from this lately on my PRs, and on main.

For example, this commit from main failed from this in ReactFlightDOMEdge.

This test failed on my latest PR also from ReactFlightDOMEdge.

But aside from CI, I can basically repro locally any time I run yarn test, which makes it really annoying to test my changes before pushing.

@rickhanlonii

rickhanlonii commented Jan 18, 2026

Copy link
Copy Markdown
ContributorAuthor

The root cause seems to be that when those tests are run alongside other tests, the timing changes due to subtle delays in execution caused by the other test runs.

@rickhanlonii
rickhanloniiforce-pushed the fix-reactflight-test-flaky-time-values branch from a738e51 to e01bf9bCompareJanuary 18, 2026 19:17
@rickhanloniirickhanlonii changed the title [tests] Fix flaky time values in ReactFlight-test.js[tests] Fix flaky flight testsJan 18, 2026
@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I found the root cause, see the new description and fixes - none of the test snapshots need to change now.

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Makes sense!

@rickhanlonii
rickhanlonii merged commit 195fd22 into react:mainJan 18, 2026
234 checks passed
@rickhanlonii
rickhanlonii deleted the fix-reactflight-test-flaky-time-values branch January 18, 2026 20:36
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedReact Core TeamOpened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rickhanlonii@react-sizebot@unstubbable
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [tests] Fix flaky flight tests by rickhanlonii · Pull Request #35513 · react/react · GitHub
Skip to content

[tests] Fix flaky flight tests - #35513

Merged
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values
Jan 18, 2026
Merged

[tests] Fix flaky flight tests#35513
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values

Conversation

@rickhanlonii

@rickhanloniirickhanlonii commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Flights tests are failing locally and in CI non-deterministically because we're not disabling async hooks after tests, and GC can clear WeakRefs non-deterministically.

This PR fixes the issue by adding an afterEach to disable installed hooks, and normalizing the value to value: {value: undefined}} when snapshotting.

Claude found the fix, here's the explanation:

Summary of Both Flaky Test Issues

Issue 1: ReactFlightDOMEdge-test.js - Cross-Test Async Hook Pollution

Root Cause:

  • When tests run with --runInBand, they execute sequentially in the same process
  • ReactFlightAsyncDebugInfo-test.js loads the Node server which creates async hooks via createHook().enable() to track async operations
  • ReactFlightDOMEdge-test.js loads the Edge server which uses a Noop debug config (no async hooks created) - The async hooks from the Node server persisted across tests because:
    • The Edge server doesn't create new hooks, so the cleanup code in setupTests.js never triggered
    • Old hooks kept firing their callbacks, calling performance.now() on the Edge test's mocks
    • This caused the Edge test's time values to be 232, 259, 260 instead of expected 12, 13, 14

The Fix: scripts/jest/setupTests.js

afterEach(() => {
if (installedHook) {
installedHook.disable();
installedHook = null;
}
});

This ensures async hooks are disabled after each test, preventing cross-test pollution.

Issue 2: ReactFlightAsyncDebugInfo-test.js - WeakRef Garbage Collection

Root Cause:

  • React's async debug info uses WeakRef to hold references to promises without preventing garbage collection
  • When serializing debug info, the code calls weakRef.deref() to get the promise
  • If GC has run: deref() returns undefined, and the server doesn't include the value field at all
  • If GC hasn't run: deref() returns the promise, and the server includes value: { value: undefined }
  • Since GC timing is non-deterministic (depends on memory pressure, CPU, etc.), tests would randomly pass or fail

The Fix: packages/internal-test-utils/debugInfo.js

// In normalizeIOInfo()
} else if ('value' in ioInfo) {
// If value exists but is undefined (WeakRef was GC'd)
copy.value = { value: undefined };
} else if (ioInfo.name && ioInfo.name !== 'rsc stream') {
// If value is completely missing (server didn't send it due to GC)
copy.value = { value: undefined };
}

This normalizes the output so snapshots always see a consistent structure regardless of GC timing.


★ Insight ─────────────────────────────────────
Two Patterns for Flaky Tests:

  1. State Leakage Between Tests: When tests run sequentially, global state (like async hooks, timers, or singletons) can leak. Solution: Clean up thoroughly in afterEach.
  2. Non-Deterministic System Behavior: When tests depend on unpredictable behavior (GC timing, network timing, file system operations), normalize the data in test utilities rather than trying to control the underlying system.
    ─────────────────────────────────────────────────

Both issues shared a common theme: non-deterministic behavior in sequential test execution. The first was about test isolation failure, the second was about normalizing inherently non-deterministic runtime behavior.

@rickhanloniirickhanlonii changed the title Fix flaky time values in ReactFlight-test.js[tests] Fix flaky time values in ReactFlight-test.jsJan 15, 2026
@github-actionsgithub-actionsBot added the React Core Team Opened by a member of the React Core Team label Jan 15, 2026
@react-sizebot

react-sizebot commented Jan 15, 2026

Copy link
Copy Markdown

Comparing: d87298a...e01bf9b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-stable/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js=608.48 kB608.03 kB+0.01%107.60 kB107.61 kB
oss-experimental/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
facebook-www/ReactDOM-prod.classic.js=693.87 kB693.38 kB+0.02%121.97 kB122.00 kB
facebook-www/ReactDOM-prod.modern.js=684.25 kB683.76 kB+0.02%120.37 kB120.40 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-experimental/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-experimental/react-art/cjs/react-art.production.js=358.82 kB357.47 kB=60.39 kB60.22 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js=1,262.88 kB1,257.62 kB=209.88 kB208.89 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js=1,262.87 kB1,257.62 kB=210.68 kB209.73 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js=1,246.33 kB1,241.07 kB=207.01 kB206.04 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js=685.36 kB681.67 kB=121.56 kB121.07 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js=862.57 kB857.88 kB=134.34 kB133.50 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
oss-experimental/react-dom/cjs/react-dom-profiling.profiling.js=750.23 kB745.88 kB=129.58 kB128.84 kB
oss-experimental/react-art/cjs/react-art.development.js=734.08 kB729.74 kB=115.50 kB114.68 kB
facebook-react-native/react/cjs/React-dev.js=52.93 kB52.61 kB=11.64 kB11.61 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js=491.86 kB488.70 kB=78.14 kB77.71 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js=568.03 kB564.15 kB=88.36 kB87.75 kB
facebook-www/React-profiling.classic.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-profiling.modern.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-prod.classic.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-www/React-prod.modern.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-react-native/react/cjs/React-profiling.js=19.96 kB19.66 kB=5.06 kB5.03 kB
oss-experimental/react/cjs/react.production.js=19.76 kB19.46 kB=4.95 kB4.92 kB
facebook-react-native/react/cjs/React-prod.js=19.53 kB19.23 kB=4.98 kB4.95 kB
oss-experimental/react/cjs/react.react-server.production.js=19.41 kB19.11 kB=5.03 kB5.00 kB
oss-stable/react/cjs/react.production.js=18.07 kB17.77 kB=4.62 kB4.59 kB
oss-stable-semver/react/cjs/react.production.js=18.04 kB17.74 kB=4.60 kB4.57 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Generated by 🚫 dangerJS against e01bf9b

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As far as I understand these tests do care about the debug info entries with the mocked time (introduced in #31716). For example, you want to assert that they are sequential and not overlapping, which is why there are also comments like Clamped to the start. So they are roughly asserting how this would lay out in the performance tracks. I've also never seen them flake. Under which circumstances did that happen to you?

@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I've seen CI fail quite a few times from this lately on my PRs, and on main.

For example, this commit from main failed from this in ReactFlightDOMEdge.

This test failed on my latest PR also from ReactFlightDOMEdge.

But aside from CI, I can basically repro locally any time I run yarn test, which makes it really annoying to test my changes before pushing.

@rickhanlonii

rickhanlonii commented Jan 18, 2026

Copy link
Copy Markdown
ContributorAuthor

The root cause seems to be that when those tests are run alongside other tests, the timing changes due to subtle delays in execution caused by the other test runs.

@rickhanlonii
rickhanloniiforce-pushed the fix-reactflight-test-flaky-time-values branch from a738e51 to e01bf9bCompareJanuary 18, 2026 19:17
@rickhanloniirickhanlonii changed the title [tests] Fix flaky time values in ReactFlight-test.js[tests] Fix flaky flight testsJan 18, 2026
@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I found the root cause, see the new description and fixes - none of the test snapshots need to change now.

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Makes sense!

@rickhanlonii
rickhanlonii merged commit 195fd22 into react:mainJan 18, 2026
234 checks passed
@rickhanlonii
rickhanlonii deleted the fix-reactflight-test-flaky-time-values branch January 18, 2026 20:36
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedReact Core TeamOpened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rickhanlonii@react-sizebot@unstubbable
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' [tests] Fix flaky flight tests by rickhanlonii · Pull Request #35513 · react/react · GitHub
Skip to content

[tests] Fix flaky flight tests - #35513

Merged
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values
Jan 18, 2026
Merged

[tests] Fix flaky flight tests#35513
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values

Conversation

@rickhanlonii

@rickhanloniirickhanlonii commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Flights tests are failing locally and in CI non-deterministically because we're not disabling async hooks after tests, and GC can clear WeakRefs non-deterministically.

This PR fixes the issue by adding an afterEach to disable installed hooks, and normalizing the value to value: {value: undefined}} when snapshotting.

Claude found the fix, here's the explanation:

Summary of Both Flaky Test Issues

Issue 1: ReactFlightDOMEdge-test.js - Cross-Test Async Hook Pollution

Root Cause:

  • When tests run with --runInBand, they execute sequentially in the same process
  • ReactFlightAsyncDebugInfo-test.js loads the Node server which creates async hooks via createHook().enable() to track async operations
  • ReactFlightDOMEdge-test.js loads the Edge server which uses a Noop debug config (no async hooks created) - The async hooks from the Node server persisted across tests because:
    • The Edge server doesn't create new hooks, so the cleanup code in setupTests.js never triggered
    • Old hooks kept firing their callbacks, calling performance.now() on the Edge test's mocks
    • This caused the Edge test's time values to be 232, 259, 260 instead of expected 12, 13, 14

The Fix: scripts/jest/setupTests.js

afterEach(() => {
if (installedHook) {
installedHook.disable();
installedHook = null;
}
});

This ensures async hooks are disabled after each test, preventing cross-test pollution.

Issue 2: ReactFlightAsyncDebugInfo-test.js - WeakRef Garbage Collection

Root Cause:

  • React's async debug info uses WeakRef to hold references to promises without preventing garbage collection
  • When serializing debug info, the code calls weakRef.deref() to get the promise
  • If GC has run: deref() returns undefined, and the server doesn't include the value field at all
  • If GC hasn't run: deref() returns the promise, and the server includes value: { value: undefined }
  • Since GC timing is non-deterministic (depends on memory pressure, CPU, etc.), tests would randomly pass or fail

The Fix: packages/internal-test-utils/debugInfo.js

// In normalizeIOInfo()
} else if ('value' in ioInfo) {
// If value exists but is undefined (WeakRef was GC'd)
copy.value = { value: undefined };
} else if (ioInfo.name && ioInfo.name !== 'rsc stream') {
// If value is completely missing (server didn't send it due to GC)
copy.value = { value: undefined };
}

This normalizes the output so snapshots always see a consistent structure regardless of GC timing.


★ Insight ─────────────────────────────────────
Two Patterns for Flaky Tests:

  1. State Leakage Between Tests: When tests run sequentially, global state (like async hooks, timers, or singletons) can leak. Solution: Clean up thoroughly in afterEach.
  2. Non-Deterministic System Behavior: When tests depend on unpredictable behavior (GC timing, network timing, file system operations), normalize the data in test utilities rather than trying to control the underlying system.
    ─────────────────────────────────────────────────

Both issues shared a common theme: non-deterministic behavior in sequential test execution. The first was about test isolation failure, the second was about normalizing inherently non-deterministic runtime behavior.

@rickhanloniirickhanlonii changed the title Fix flaky time values in ReactFlight-test.js[tests] Fix flaky time values in ReactFlight-test.jsJan 15, 2026
@github-actionsgithub-actionsBot added the React Core Team Opened by a member of the React Core Team label Jan 15, 2026
@react-sizebot

react-sizebot commented Jan 15, 2026

Copy link
Copy Markdown

Comparing: d87298a...e01bf9b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-stable/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js=608.48 kB608.03 kB+0.01%107.60 kB107.61 kB
oss-experimental/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
facebook-www/ReactDOM-prod.classic.js=693.87 kB693.38 kB+0.02%121.97 kB122.00 kB
facebook-www/ReactDOM-prod.modern.js=684.25 kB683.76 kB+0.02%120.37 kB120.40 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-experimental/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-experimental/react-art/cjs/react-art.production.js=358.82 kB357.47 kB=60.39 kB60.22 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js=1,262.88 kB1,257.62 kB=209.88 kB208.89 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js=1,262.87 kB1,257.62 kB=210.68 kB209.73 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js=1,246.33 kB1,241.07 kB=207.01 kB206.04 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js=685.36 kB681.67 kB=121.56 kB121.07 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js=862.57 kB857.88 kB=134.34 kB133.50 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
oss-experimental/react-dom/cjs/react-dom-profiling.profiling.js=750.23 kB745.88 kB=129.58 kB128.84 kB
oss-experimental/react-art/cjs/react-art.development.js=734.08 kB729.74 kB=115.50 kB114.68 kB
facebook-react-native/react/cjs/React-dev.js=52.93 kB52.61 kB=11.64 kB11.61 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js=491.86 kB488.70 kB=78.14 kB77.71 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js=568.03 kB564.15 kB=88.36 kB87.75 kB
facebook-www/React-profiling.classic.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-profiling.modern.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-prod.classic.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-www/React-prod.modern.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-react-native/react/cjs/React-profiling.js=19.96 kB19.66 kB=5.06 kB5.03 kB
oss-experimental/react/cjs/react.production.js=19.76 kB19.46 kB=4.95 kB4.92 kB
facebook-react-native/react/cjs/React-prod.js=19.53 kB19.23 kB=4.98 kB4.95 kB
oss-experimental/react/cjs/react.react-server.production.js=19.41 kB19.11 kB=5.03 kB5.00 kB
oss-stable/react/cjs/react.production.js=18.07 kB17.77 kB=4.62 kB4.59 kB
oss-stable-semver/react/cjs/react.production.js=18.04 kB17.74 kB=4.60 kB4.57 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Generated by 🚫 dangerJS against e01bf9b

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As far as I understand these tests do care about the debug info entries with the mocked time (introduced in #31716). For example, you want to assert that they are sequential and not overlapping, which is why there are also comments like Clamped to the start. So they are roughly asserting how this would lay out in the performance tracks. I've also never seen them flake. Under which circumstances did that happen to you?

@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I've seen CI fail quite a few times from this lately on my PRs, and on main.

For example, this commit from main failed from this in ReactFlightDOMEdge.

This test failed on my latest PR also from ReactFlightDOMEdge.

But aside from CI, I can basically repro locally any time I run yarn test, which makes it really annoying to test my changes before pushing.

@rickhanlonii

rickhanlonii commented Jan 18, 2026

Copy link
Copy Markdown
ContributorAuthor

The root cause seems to be that when those tests are run alongside other tests, the timing changes due to subtle delays in execution caused by the other test runs.

@rickhanlonii
rickhanloniiforce-pushed the fix-reactflight-test-flaky-time-values branch from a738e51 to e01bf9bCompareJanuary 18, 2026 19:17
@rickhanloniirickhanlonii changed the title [tests] Fix flaky time values in ReactFlight-test.js[tests] Fix flaky flight testsJan 18, 2026
@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I found the root cause, see the new description and fixes - none of the test snapshots need to change now.

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Makes sense!

@rickhanlonii
rickhanlonii merged commit 195fd22 into react:mainJan 18, 2026
234 checks passed
@rickhanlonii
rickhanlonii deleted the fix-reactflight-test-flaky-time-values branch January 18, 2026 20:36
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedReact Core TeamOpened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rickhanlonii@react-sizebot@unstubbable
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [tests] Fix flaky flight tests by rickhanlonii · Pull Request #35513 · react/react · GitHub
Skip to content

[tests] Fix flaky flight tests - #35513

Merged
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values
Jan 18, 2026
Merged

[tests] Fix flaky flight tests#35513
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values

Conversation

@rickhanlonii

@rickhanloniirickhanlonii commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Flights tests are failing locally and in CI non-deterministically because we're not disabling async hooks after tests, and GC can clear WeakRefs non-deterministically.

This PR fixes the issue by adding an afterEach to disable installed hooks, and normalizing the value to value: {value: undefined}} when snapshotting.

Claude found the fix, here's the explanation:

Summary of Both Flaky Test Issues

Issue 1: ReactFlightDOMEdge-test.js - Cross-Test Async Hook Pollution

Root Cause:

  • When tests run with --runInBand, they execute sequentially in the same process
  • ReactFlightAsyncDebugInfo-test.js loads the Node server which creates async hooks via createHook().enable() to track async operations
  • ReactFlightDOMEdge-test.js loads the Edge server which uses a Noop debug config (no async hooks created) - The async hooks from the Node server persisted across tests because:
    • The Edge server doesn't create new hooks, so the cleanup code in setupTests.js never triggered
    • Old hooks kept firing their callbacks, calling performance.now() on the Edge test's mocks
    • This caused the Edge test's time values to be 232, 259, 260 instead of expected 12, 13, 14

The Fix: scripts/jest/setupTests.js

afterEach(() => {
if (installedHook) {
installedHook.disable();
installedHook = null;
}
});

This ensures async hooks are disabled after each test, preventing cross-test pollution.

Issue 2: ReactFlightAsyncDebugInfo-test.js - WeakRef Garbage Collection

Root Cause:

  • React's async debug info uses WeakRef to hold references to promises without preventing garbage collection
  • When serializing debug info, the code calls weakRef.deref() to get the promise
  • If GC has run: deref() returns undefined, and the server doesn't include the value field at all
  • If GC hasn't run: deref() returns the promise, and the server includes value: { value: undefined }
  • Since GC timing is non-deterministic (depends on memory pressure, CPU, etc.), tests would randomly pass or fail

The Fix: packages/internal-test-utils/debugInfo.js

// In normalizeIOInfo()
} else if ('value' in ioInfo) {
// If value exists but is undefined (WeakRef was GC'd)
copy.value = { value: undefined };
} else if (ioInfo.name && ioInfo.name !== 'rsc stream') {
// If value is completely missing (server didn't send it due to GC)
copy.value = { value: undefined };
}

This normalizes the output so snapshots always see a consistent structure regardless of GC timing.


★ Insight ─────────────────────────────────────
Two Patterns for Flaky Tests:

  1. State Leakage Between Tests: When tests run sequentially, global state (like async hooks, timers, or singletons) can leak. Solution: Clean up thoroughly in afterEach.
  2. Non-Deterministic System Behavior: When tests depend on unpredictable behavior (GC timing, network timing, file system operations), normalize the data in test utilities rather than trying to control the underlying system.
    ─────────────────────────────────────────────────

Both issues shared a common theme: non-deterministic behavior in sequential test execution. The first was about test isolation failure, the second was about normalizing inherently non-deterministic runtime behavior.

@rickhanloniirickhanlonii changed the title Fix flaky time values in ReactFlight-test.js[tests] Fix flaky time values in ReactFlight-test.jsJan 15, 2026
@github-actionsgithub-actionsBot added the React Core Team Opened by a member of the React Core Team label Jan 15, 2026
@react-sizebot

react-sizebot commented Jan 15, 2026

Copy link
Copy Markdown

Comparing: d87298a...e01bf9b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-stable/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js=608.48 kB608.03 kB+0.01%107.60 kB107.61 kB
oss-experimental/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
facebook-www/ReactDOM-prod.classic.js=693.87 kB693.38 kB+0.02%121.97 kB122.00 kB
facebook-www/ReactDOM-prod.modern.js=684.25 kB683.76 kB+0.02%120.37 kB120.40 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-experimental/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-experimental/react-art/cjs/react-art.production.js=358.82 kB357.47 kB=60.39 kB60.22 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js=1,262.88 kB1,257.62 kB=209.88 kB208.89 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js=1,262.87 kB1,257.62 kB=210.68 kB209.73 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js=1,246.33 kB1,241.07 kB=207.01 kB206.04 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js=685.36 kB681.67 kB=121.56 kB121.07 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js=862.57 kB857.88 kB=134.34 kB133.50 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
oss-experimental/react-dom/cjs/react-dom-profiling.profiling.js=750.23 kB745.88 kB=129.58 kB128.84 kB
oss-experimental/react-art/cjs/react-art.development.js=734.08 kB729.74 kB=115.50 kB114.68 kB
facebook-react-native/react/cjs/React-dev.js=52.93 kB52.61 kB=11.64 kB11.61 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js=491.86 kB488.70 kB=78.14 kB77.71 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js=568.03 kB564.15 kB=88.36 kB87.75 kB
facebook-www/React-profiling.classic.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-profiling.modern.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-prod.classic.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-www/React-prod.modern.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-react-native/react/cjs/React-profiling.js=19.96 kB19.66 kB=5.06 kB5.03 kB
oss-experimental/react/cjs/react.production.js=19.76 kB19.46 kB=4.95 kB4.92 kB
facebook-react-native/react/cjs/React-prod.js=19.53 kB19.23 kB=4.98 kB4.95 kB
oss-experimental/react/cjs/react.react-server.production.js=19.41 kB19.11 kB=5.03 kB5.00 kB
oss-stable/react/cjs/react.production.js=18.07 kB17.77 kB=4.62 kB4.59 kB
oss-stable-semver/react/cjs/react.production.js=18.04 kB17.74 kB=4.60 kB4.57 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Generated by 🚫 dangerJS against e01bf9b

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As far as I understand these tests do care about the debug info entries with the mocked time (introduced in #31716). For example, you want to assert that they are sequential and not overlapping, which is why there are also comments like Clamped to the start. So they are roughly asserting how this would lay out in the performance tracks. I've also never seen them flake. Under which circumstances did that happen to you?

@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I've seen CI fail quite a few times from this lately on my PRs, and on main.

For example, this commit from main failed from this in ReactFlightDOMEdge.

This test failed on my latest PR also from ReactFlightDOMEdge.

But aside from CI, I can basically repro locally any time I run yarn test, which makes it really annoying to test my changes before pushing.

@rickhanlonii

rickhanlonii commented Jan 18, 2026

Copy link
Copy Markdown
ContributorAuthor

The root cause seems to be that when those tests are run alongside other tests, the timing changes due to subtle delays in execution caused by the other test runs.

@rickhanlonii
rickhanloniiforce-pushed the fix-reactflight-test-flaky-time-values branch from a738e51 to e01bf9bCompareJanuary 18, 2026 19:17
@rickhanloniirickhanlonii changed the title [tests] Fix flaky time values in ReactFlight-test.js[tests] Fix flaky flight testsJan 18, 2026
@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I found the root cause, see the new description and fixes - none of the test snapshots need to change now.

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Makes sense!

@rickhanlonii
rickhanlonii merged commit 195fd22 into react:mainJan 18, 2026
234 checks passed
@rickhanlonii
rickhanlonii deleted the fix-reactflight-test-flaky-time-values branch January 18, 2026 20:36
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedReact Core TeamOpened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rickhanlonii@react-sizebot@unstubbable
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [tests] Fix flaky flight tests by rickhanlonii · Pull Request #35513 · react/react · GitHub
Skip to content

[tests] Fix flaky flight tests - #35513

Merged
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values
Jan 18, 2026
Merged

[tests] Fix flaky flight tests#35513
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values

Conversation

@rickhanlonii

@rickhanloniirickhanlonii commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Flights tests are failing locally and in CI non-deterministically because we're not disabling async hooks after tests, and GC can clear WeakRefs non-deterministically.

This PR fixes the issue by adding an afterEach to disable installed hooks, and normalizing the value to value: {value: undefined}} when snapshotting.

Claude found the fix, here's the explanation:

Summary of Both Flaky Test Issues

Issue 1: ReactFlightDOMEdge-test.js - Cross-Test Async Hook Pollution

Root Cause:

  • When tests run with --runInBand, they execute sequentially in the same process
  • ReactFlightAsyncDebugInfo-test.js loads the Node server which creates async hooks via createHook().enable() to track async operations
  • ReactFlightDOMEdge-test.js loads the Edge server which uses a Noop debug config (no async hooks created) - The async hooks from the Node server persisted across tests because:
    • The Edge server doesn't create new hooks, so the cleanup code in setupTests.js never triggered
    • Old hooks kept firing their callbacks, calling performance.now() on the Edge test's mocks
    • This caused the Edge test's time values to be 232, 259, 260 instead of expected 12, 13, 14

The Fix: scripts/jest/setupTests.js

afterEach(() => {
if (installedHook) {
installedHook.disable();
installedHook = null;
}
});

This ensures async hooks are disabled after each test, preventing cross-test pollution.

Issue 2: ReactFlightAsyncDebugInfo-test.js - WeakRef Garbage Collection

Root Cause:

  • React's async debug info uses WeakRef to hold references to promises without preventing garbage collection
  • When serializing debug info, the code calls weakRef.deref() to get the promise
  • If GC has run: deref() returns undefined, and the server doesn't include the value field at all
  • If GC hasn't run: deref() returns the promise, and the server includes value: { value: undefined }
  • Since GC timing is non-deterministic (depends on memory pressure, CPU, etc.), tests would randomly pass or fail

The Fix: packages/internal-test-utils/debugInfo.js

// In normalizeIOInfo()
} else if ('value' in ioInfo) {
// If value exists but is undefined (WeakRef was GC'd)
copy.value = { value: undefined };
} else if (ioInfo.name && ioInfo.name !== 'rsc stream') {
// If value is completely missing (server didn't send it due to GC)
copy.value = { value: undefined };
}

This normalizes the output so snapshots always see a consistent structure regardless of GC timing.


★ Insight ─────────────────────────────────────
Two Patterns for Flaky Tests:

  1. State Leakage Between Tests: When tests run sequentially, global state (like async hooks, timers, or singletons) can leak. Solution: Clean up thoroughly in afterEach.
  2. Non-Deterministic System Behavior: When tests depend on unpredictable behavior (GC timing, network timing, file system operations), normalize the data in test utilities rather than trying to control the underlying system.
    ─────────────────────────────────────────────────

Both issues shared a common theme: non-deterministic behavior in sequential test execution. The first was about test isolation failure, the second was about normalizing inherently non-deterministic runtime behavior.

@rickhanloniirickhanlonii changed the title Fix flaky time values in ReactFlight-test.js[tests] Fix flaky time values in ReactFlight-test.jsJan 15, 2026
@github-actionsgithub-actionsBot added the React Core Team Opened by a member of the React Core Team label Jan 15, 2026
@react-sizebot

react-sizebot commented Jan 15, 2026

Copy link
Copy Markdown

Comparing: d87298a...e01bf9b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-stable/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js=608.48 kB608.03 kB+0.01%107.60 kB107.61 kB
oss-experimental/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
facebook-www/ReactDOM-prod.classic.js=693.87 kB693.38 kB+0.02%121.97 kB122.00 kB
facebook-www/ReactDOM-prod.modern.js=684.25 kB683.76 kB+0.02%120.37 kB120.40 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-experimental/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-experimental/react-art/cjs/react-art.production.js=358.82 kB357.47 kB=60.39 kB60.22 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js=1,262.88 kB1,257.62 kB=209.88 kB208.89 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js=1,262.87 kB1,257.62 kB=210.68 kB209.73 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js=1,246.33 kB1,241.07 kB=207.01 kB206.04 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js=685.36 kB681.67 kB=121.56 kB121.07 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js=862.57 kB857.88 kB=134.34 kB133.50 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
oss-experimental/react-dom/cjs/react-dom-profiling.profiling.js=750.23 kB745.88 kB=129.58 kB128.84 kB
oss-experimental/react-art/cjs/react-art.development.js=734.08 kB729.74 kB=115.50 kB114.68 kB
facebook-react-native/react/cjs/React-dev.js=52.93 kB52.61 kB=11.64 kB11.61 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js=491.86 kB488.70 kB=78.14 kB77.71 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js=568.03 kB564.15 kB=88.36 kB87.75 kB
facebook-www/React-profiling.classic.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-profiling.modern.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-prod.classic.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-www/React-prod.modern.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-react-native/react/cjs/React-profiling.js=19.96 kB19.66 kB=5.06 kB5.03 kB
oss-experimental/react/cjs/react.production.js=19.76 kB19.46 kB=4.95 kB4.92 kB
facebook-react-native/react/cjs/React-prod.js=19.53 kB19.23 kB=4.98 kB4.95 kB
oss-experimental/react/cjs/react.react-server.production.js=19.41 kB19.11 kB=5.03 kB5.00 kB
oss-stable/react/cjs/react.production.js=18.07 kB17.77 kB=4.62 kB4.59 kB
oss-stable-semver/react/cjs/react.production.js=18.04 kB17.74 kB=4.60 kB4.57 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Generated by 🚫 dangerJS against e01bf9b

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As far as I understand these tests do care about the debug info entries with the mocked time (introduced in #31716). For example, you want to assert that they are sequential and not overlapping, which is why there are also comments like Clamped to the start. So they are roughly asserting how this would lay out in the performance tracks. I've also never seen them flake. Under which circumstances did that happen to you?

@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I've seen CI fail quite a few times from this lately on my PRs, and on main.

For example, this commit from main failed from this in ReactFlightDOMEdge.

This test failed on my latest PR also from ReactFlightDOMEdge.

But aside from CI, I can basically repro locally any time I run yarn test, which makes it really annoying to test my changes before pushing.

@rickhanlonii

rickhanlonii commented Jan 18, 2026

Copy link
Copy Markdown
ContributorAuthor

The root cause seems to be that when those tests are run alongside other tests, the timing changes due to subtle delays in execution caused by the other test runs.

@rickhanlonii
rickhanloniiforce-pushed the fix-reactflight-test-flaky-time-values branch from a738e51 to e01bf9bCompareJanuary 18, 2026 19:17
@rickhanloniirickhanlonii changed the title [tests] Fix flaky time values in ReactFlight-test.js[tests] Fix flaky flight testsJan 18, 2026
@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I found the root cause, see the new description and fixes - none of the test snapshots need to change now.

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Makes sense!

@rickhanlonii
rickhanlonii merged commit 195fd22 into react:mainJan 18, 2026
234 checks passed
@rickhanlonii
rickhanlonii deleted the fix-reactflight-test-flaky-time-values branch January 18, 2026 20:36
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedReact Core TeamOpened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rickhanlonii@react-sizebot@unstubbable
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); [tests] Fix flaky flight tests by rickhanlonii · Pull Request #35513 · react/react · GitHub
Skip to content

[tests] Fix flaky flight tests - #35513

Merged
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values
Jan 18, 2026
Merged

[tests] Fix flaky flight tests#35513
rickhanlonii merged 1 commit into
react:mainfrom
rickhanlonii:fix-reactflight-test-flaky-time-values

Conversation

@rickhanlonii

@rickhanloniirickhanlonii commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Flights tests are failing locally and in CI non-deterministically because we're not disabling async hooks after tests, and GC can clear WeakRefs non-deterministically.

This PR fixes the issue by adding an afterEach to disable installed hooks, and normalizing the value to value: {value: undefined}} when snapshotting.

Claude found the fix, here's the explanation:

Summary of Both Flaky Test Issues

Issue 1: ReactFlightDOMEdge-test.js - Cross-Test Async Hook Pollution

Root Cause:

  • When tests run with --runInBand, they execute sequentially in the same process
  • ReactFlightAsyncDebugInfo-test.js loads the Node server which creates async hooks via createHook().enable() to track async operations
  • ReactFlightDOMEdge-test.js loads the Edge server which uses a Noop debug config (no async hooks created) - The async hooks from the Node server persisted across tests because:
    • The Edge server doesn't create new hooks, so the cleanup code in setupTests.js never triggered
    • Old hooks kept firing their callbacks, calling performance.now() on the Edge test's mocks
    • This caused the Edge test's time values to be 232, 259, 260 instead of expected 12, 13, 14

The Fix: scripts/jest/setupTests.js

afterEach(() => {
if (installedHook) {
installedHook.disable();
installedHook = null;
}
});

This ensures async hooks are disabled after each test, preventing cross-test pollution.

Issue 2: ReactFlightAsyncDebugInfo-test.js - WeakRef Garbage Collection

Root Cause:

  • React's async debug info uses WeakRef to hold references to promises without preventing garbage collection
  • When serializing debug info, the code calls weakRef.deref() to get the promise
  • If GC has run: deref() returns undefined, and the server doesn't include the value field at all
  • If GC hasn't run: deref() returns the promise, and the server includes value: { value: undefined }
  • Since GC timing is non-deterministic (depends on memory pressure, CPU, etc.), tests would randomly pass or fail

The Fix: packages/internal-test-utils/debugInfo.js

// In normalizeIOInfo()
} else if ('value' in ioInfo) {
// If value exists but is undefined (WeakRef was GC'd)
copy.value = { value: undefined };
} else if (ioInfo.name && ioInfo.name !== 'rsc stream') {
// If value is completely missing (server didn't send it due to GC)
copy.value = { value: undefined };
}

This normalizes the output so snapshots always see a consistent structure regardless of GC timing.


★ Insight ─────────────────────────────────────
Two Patterns for Flaky Tests:

  1. State Leakage Between Tests: When tests run sequentially, global state (like async hooks, timers, or singletons) can leak. Solution: Clean up thoroughly in afterEach.
  2. Non-Deterministic System Behavior: When tests depend on unpredictable behavior (GC timing, network timing, file system operations), normalize the data in test utilities rather than trying to control the underlying system.
    ─────────────────────────────────────────────────

Both issues shared a common theme: non-deterministic behavior in sequential test execution. The first was about test isolation failure, the second was about normalizing inherently non-deterministic runtime behavior.

@rickhanloniirickhanlonii changed the title Fix flaky time values in ReactFlight-test.js[tests] Fix flaky time values in ReactFlight-test.jsJan 15, 2026
@github-actionsgithub-actionsBot added the React Core Team Opened by a member of the React Core Team label Jan 15, 2026
@react-sizebot

react-sizebot commented Jan 15, 2026

Copy link
Copy Markdown

Comparing: d87298a...e01bf9b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-stable/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js=608.48 kB608.03 kB+0.01%107.60 kB107.61 kB
oss-experimental/react-dom/cjs/react-dom.production.js=6.84 kB6.84 kB=1.88 kB1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
facebook-www/ReactDOM-prod.classic.js=693.87 kB693.38 kB+0.02%121.97 kB122.00 kB
facebook-www/ReactDOM-prod.modern.js=684.25 kB683.76 kB+0.02%120.37 kB120.40 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name+/-BaseCurrent+/- gzipBase gzipCurrent gzip
oss-experimental/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.development.js=33.37 kB33.29 kB=5.93 kB5.92 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.production.js=29.78 kB29.70 kB=5.81 kB5.80 kB
oss-experimental/react-art/cjs/react-art.production.js=358.82 kB357.47 kB=60.39 kB60.22 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js=1,262.88 kB1,257.62 kB=209.88 kB208.89 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js=1,262.87 kB1,257.62 kB=210.68 kB209.73 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js=1,246.33 kB1,241.07 kB=207.01 kB206.04 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js=685.36 kB681.67 kB=121.56 kB121.07 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js=862.57 kB857.88 kB=134.34 kB133.50 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js=670.95 kB667.26 kB=118.02 kB117.51 kB
oss-experimental/react-dom/cjs/react-dom-profiling.profiling.js=750.23 kB745.88 kB=129.58 kB128.84 kB
oss-experimental/react-art/cjs/react-art.development.js=734.08 kB729.74 kB=115.50 kB114.68 kB
facebook-react-native/react/cjs/React-dev.js=52.93 kB52.61 kB=11.64 kB11.61 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js=491.86 kB488.70 kB=78.14 kB77.71 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js=568.03 kB564.15 kB=88.36 kB87.75 kB
facebook-www/React-profiling.classic.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-profiling.modern.js=20.87 kB20.57 kB=5.28 kB5.25 kB
facebook-www/React-prod.classic.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-www/React-prod.modern.js=20.44 kB20.14 kB=5.20 kB5.17 kB
facebook-react-native/react/cjs/React-profiling.js=19.96 kB19.66 kB=5.06 kB5.03 kB
oss-experimental/react/cjs/react.production.js=19.76 kB19.46 kB=4.95 kB4.92 kB
facebook-react-native/react/cjs/React-prod.js=19.53 kB19.23 kB=4.98 kB4.95 kB
oss-experimental/react/cjs/react.react-server.production.js=19.41 kB19.11 kB=5.03 kB5.00 kB
oss-stable/react/cjs/react.production.js=18.07 kB17.77 kB=4.62 kB4.59 kB
oss-stable-semver/react/cjs/react.production.js=18.04 kB17.74 kB=4.60 kB4.57 kB
oss-stable/react/cjs/react.react-server.production.js=13.83 kB13.54 kB=3.76 kB3.74 kB
oss-stable-semver/react/cjs/react.react-server.production.js=13.81 kB13.51 kB=3.74 kB3.71 kB

Generated by 🚫 dangerJS against e01bf9b

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As far as I understand these tests do care about the debug info entries with the mocked time (introduced in #31716). For example, you want to assert that they are sequential and not overlapping, which is why there are also comments like Clamped to the start. So they are roughly asserting how this would lay out in the performance tracks. I've also never seen them flake. Under which circumstances did that happen to you?

@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I've seen CI fail quite a few times from this lately on my PRs, and on main.

For example, this commit from main failed from this in ReactFlightDOMEdge.

This test failed on my latest PR also from ReactFlightDOMEdge.

But aside from CI, I can basically repro locally any time I run yarn test, which makes it really annoying to test my changes before pushing.

@rickhanlonii

rickhanlonii commented Jan 18, 2026

Copy link
Copy Markdown
ContributorAuthor

The root cause seems to be that when those tests are run alongside other tests, the timing changes due to subtle delays in execution caused by the other test runs.

@rickhanlonii
rickhanloniiforce-pushed the fix-reactflight-test-flaky-time-values branch from a738e51 to e01bf9bCompareJanuary 18, 2026 19:17
@rickhanloniirickhanlonii changed the title [tests] Fix flaky time values in ReactFlight-test.js[tests] Fix flaky flight testsJan 18, 2026
@rickhanlonii

Copy link
Copy Markdown
ContributorAuthor

@unstubbable I found the root cause, see the new description and fixes - none of the test snapshots need to change now.

@unstubbableunstubbable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Makes sense!

@rickhanlonii
rickhanlonii merged commit 195fd22 into react:mainJan 18, 2026
234 checks passed
@rickhanlonii
rickhanlonii deleted the fix-reactflight-test-flaky-time-values branch January 18, 2026 20:36
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedReact Core TeamOpened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rickhanlonii@react-sizebot@unstubbable