5 of 6 standards met
Summary Fixes #35821 gets stuck returning a stale value in production builds when combined with , , and . The deferred value never catches up after a state change. Root Cause When a deferred render suspends on a promise created by , each retry attempt starts from the committed fiber state where the hook deps are stale. This causes to re-execute and create a new pending promise on every retry, leading to an infinite suspend-retry loop: 1. Urgent render commits with old deferred value and old memo deps 2. Deferred render starts: returns new value, sees changed deps, creates new promise P1, suspends 3. After yielding ( -> ), P1 hasn't resolved yet (production renders are fast, ~5ms yield isn't enough) 4. Render unwinds -- clears , P1's ping is registered 5. P1 resolves, ping fires, retry is scheduled 6. Retry starts from committed state (via -> ) -- committed memo deps are still stale, so creates P2. Goto step 3. The that would allow to reuse the previous promise is only preserved during replays (same render attempt), not across retries. Why dev vs prod differs:** In dev mode, rendering is slower (extra checks/warnings), giving more time during the yield for the promise to resolve as a microtask. If it resolves during the yield, returns true and replays with the preserved . Fix For deferred lane renders (), when finds the thenable still unresolved, instead of immediately unwinding the stack: 1. Transition to state 2. Register an listener on the thenable 3. Break out of the work loop This preserves the work-in-progress hooks (including the with the pending promise). When the promise resolves: The callback changes the reason to and schedules the root On resume, returns true replays with the preserved , reusing the now-resolved promise This is safe for deferred renders because: They are invisible (not yet committed), so the previous UI stays on screen The scheduler properly skips the root while suspended on data () New urgent updates correctly interrupt the waiting render via Test Plan Added regression test: All existing , , , , and tests pass (138+ tests) Reproduction steps from issue In production Next.js builds, typing in the input causes Results to show stale data that never updates.
Repository: facebook/react. Description: The library for web and native user interfaces. Stars: 243366, Forks: 50623. Primary language: JavaScript. Languages: JavaScript (68%), TypeScript (29.1%), HTML (1.5%), CSS (1.1%), CoffeeScript (0.2%). License: MIT. Homepage: https://react.dev Topics: declarative, frontend, javascript, library, react, ui. Latest release: v19.2.4 (1mo ago). Open PRs: 100, open issues: 1043. Last activity: 2h ago. Community health: 100%. Top contributors: sebmarkbage, zpao, gaearon, acdlite, sophiebits, josephsavona, poteto, jimfb, trueadm, eps1lon and others.
JavaScript
Last 12 weeks ยท 179 commits
Summary Fixes #35923 When the component renders with an empty list (or when the portal container is missing), the component returns and the portal `useLayoutEffectrepositionToFit(ref.current, ...)ref.currentnullContextMenucontextMenu-test.jsitems` is empty (reproduces the exact error from the issue) 2. Verifies the component renders correctly when items are provided Steps to reproduce the original bug: 1. Open React DevTools 2. Record a profiling session 3. Switch to the Timeline tab 4. Right-click on the canvas area (not on a specific event) With this fix, the right-click on an empty area no longer crashes.
Summary How did you test this change?