GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Bugfix: Nested useOpaqueIdentifier references by acdlite · Pull Request #22553 · react/react Conversation
Collaborator
Fixes an issue where multiple useOpaqueIdentifier hooks are upgraded to client ids within the same render. The way the upgrade works is that useOpaqueIdentifier schedules a render phase update then throws an error to trigger React's error recovery mechanism. The normal error recovery mechanism is designed for errors that occur as a result of interleaved mutations, so we usually only retry a single time, synchronously, before giving up. useOpaqueIdentifier is different because the error its throws when upgrading is not caused by an interleaved mutation. Rather, it happens when an ID is referenced for the first time inside a client-rendered tree (i.e. something that wasn't part of the initial server render). The fact that it relies on the error recovery mechanism is an implementation detail. And a single recovery attempt may be insufficient. For example, if a parent and a child component may reference different ids, and both are mounted as a result of the same client update, that will trigger two separate error recovery attempts. Because render phase updates are not allowed when triggered from userspace — we log a warning in development to prevent them — we can assume that if something does update during the render phase, it is one of our "legit" implementation details like useOpaqueIdentifier. So we can keep retrying until we succeed — up to a limit, to protect against infinite loops. I chose 50 since that's the limit we use for commit phase updates.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsWe fire a warning in development if a component is updated during the render phase (with the exception of local hook updates, which have their own defined behavior). Because it's not a supported React pattern, we don't have that many tests that trigger this path. But it is meant to have reasonable semantics when it does happen, so that if it accidentally ships to production, the app doesn't crash unnecessarily. The behavior is not super well-defined, though. There are also some _internal_ React implementation details that intentionally to rely on this behavior. Most prominently, selective hydration and useOpaqueIdentifier. I need to tweak the behavior of render phase updates slightly as part of a fix for useOpaqueIdentifier. This shouldn't cause a user-facing change in behavior outside of useOpaqueIdentifier, but it does require that we explicitly model render phase updates.
acdlite
commented
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I split
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
acdlite
commented
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is the key part to review
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Comparing: 8ee4ff8...aca9278 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
1f7d980 to
9b06f14
Compare
8a02664 to
dd448d3
Compare
Fixes an issue where multiple useOpaqueIdentifier hooks are upgraded to client ids within the same render. The way the upgrade works is that useOpaqueIdentifier schedules a render phase update then throws an error to trigger React's error recovery mechanism. The normal error recovery mechanism is designed for errors that occur as a result of interleaved mutations, so we usually only retry a single time, synchronously, before giving up. useOpaqueIdentifier is different because the error its throws when upgrading is not caused by an interleaved mutation. Rather, it happens when an ID is referenced for the first time inside a client-rendered tree (i.e. sommething that wasn't part of the initial server render). The fact that it relies on the error recovery mechanism is an implementation detail. And a single recovery attempt may be insufficient. For example, if a parent and a child component may reference different ids, and both are mounted as a result of the same client update, that will trigger two separate error recovery attempts. Because render phase updates are not allowed when triggered from userspace — we log a warning in developement to prevent them — we can assume that if something does update during the render phase, it is one of our "legit" implementation details like useOpaqueIdentifier. So we can keep retrying until we succeed — up to a limit, to protect against inifite loops. I chose 50 since that's the limit we use for commit phase updates.
dd448d3 to
aca9278
Compare
Summary: This sync includes the following changes: - **[5cccacd](react/react@5cccacd13 )**: Upgrade useId to alpha channel ([#22674](react/react#22674)) //<Andrew Clark>// - **[75f3dde](react/react@75f3ddebf )**: Remove experimental useOpaqueIdentifier API ([#22672](react/react#22672)) //<Andrew Clark>// - **[8c4a05b](react/react@8c4a05b8f )**: Remove flow pragma comment from module registration start/stop templates ([#22670](react/react#22670)) //<Brian Vaughn>// - **[ebf9ae8](react/react@ebf9ae857 )**: useId ([#22644](react/react#22644)) //<Andrew Clark>// - **[a0d991f](react/react@a0d991fe6 )**: Re-land #22292 (remove uMS from open source build) ([#22664](react/react#22664)) //<Andrew Clark>// - **[6bce035](react/react@6bce0355c )**: Upgrade useSyncExternalStore to alpha channel ([#22662](react/react#22662)) //<Andrew Clark>// - **[7034408](react/react@7034408ff )**: Follow-up improvements to error code extraction infra ([#22516](react/react#22516)) //<Andrew Clark>// - **[90e5d36](react/react@90e5d3638 )**: chore: fix comment typo ([#22615](react/react#22615)) //<btea>// - **[3c4c1c4](react/react@3c4c1c470 )**: Remove warning for dangling passive effects ([#22609](react/react#22609)) //<Andrew Clark>// - **[d5b6b4b](react/react@d5b6b4b86 )**: Expand act warning to cover all APIs that might schedule React work ([#22607](react/react#22607)) //<Andrew Clark>// - **[fa9bea0](react/react@fa9bea0c4 )**: Initial implementation of cache cleanup ([#22510](react/react#22510)) //<Joseph Savona>// - **[0e8a5af](react/react@0e8a5aff3 )**: Scheduling Profiler: Add marks for component effects (mount and unmount) ([#22578](react/react#22578)) //<Brian Vaughn>// - **[4ba2057](react/react@4ba20579d )**: Scheduling Profiler: De-emphasize React internal frames ([#22588](react/react#22588)) //<Brian Vaughn>// - **[cdb8a1d](react/react@cdb8a1d19 )**: [Fizz] Add option to inject bootstrapping script tags after the shell is injected ([#22594](react/react#22594)) //<Sebastian Markbåge>// - **[34e4c97](react/react@34e4c9756 )**: Clear extra nodes if there's a hydration mismatch within a suspense boundary ([#22592](react/react#22592)) //<Sebastian Markbåge>// - **[02f4115](react/react@02f411578 )**: Upgrade useInsertionEffect to stable ([#22589](react/react#22589)) //<Andrew Clark>// - **[2af4a79](react/react@2af4a7933 )**: Hydrate using SuspenseComponent as the parent ([#22582](react/react#22582)) //<Sebastian Markbåge>// - **[b1acff0](react/react@b1acff0cc )**: Enable cache in test renderer ([#22580](react/react#22580)) //<Joseph Savona>// - **[996da67](react/react@996da67b2 )**: Replace global `jest` heuristic with `IS_REACT_ACT_ENVIRONMENT` ([#22562](react/react#22562)) //<Andrew Clark>// - **[163e81c](react/react@163e81c1f )**: Support disabling spurious act warnings with a global environment flag ([#22561](react/react#22561)) //<Andrew Clark>// - **[23b7dfe](react/react@23b7dfeff )**: Enable scheduling profiler for RN FB profiling builds ([#22566](react/react#22566)) //<Brian Vaughn>// - **[61455a2](react/react@61455a25b )**: Enable experimental Cache API in www TestRenderer ([#22554](react/react#22554)) //<Joseph Savona>// - **[7142d11](react/react@7142d110b )**: Bugfix: Nested useOpaqueIdentifier references ([#22553](react/react#22553)) //<Andrew Clark>// - **[1e247ff](react/react@1e247ff89 )**: Enabled scheduling profiler marks for React Native FB target ([#22544](react/react#22544)) //<Brian Vaughn>// - **[c16b005](react/react@c16b005f2 )**: Update test and stack frame code to support newer V8 stack formats ([#22477](react/react#22477)) //<Brian Vaughn>// - **[55d7500](react/react@55d75005b )**: duplicate value in variable ([#22390](react/react#22390)) //<BIKI DAS>// Changelog: [General][Changed] - React Native sync for revisions afcb9cd...3fcd81d jest_e2e[run_all_tests] Reviewed By: yungsters Differential Revision: D32065987 fbshipit-source-id: ef2d402835c981aab68ca40a894c66c1630864e9
Summary: This sync includes the following changes: - **[c0c71a8](react/react@c0c71a868 )**: Re-enable useMutableSource in internal RN ([#22750](react/react#22750)) //<Ricky>// - **[cb11155](react/react@cb11155c8 )**: Add runtime type checks around module boundary code ([#22748](react/react#22748)) //<Brian Vaughn>// - **[a04f13d](react/react@a04f13d29 )**: [email protected] //<Dan Abramov>// - **[ff9897d](react/react@ff9897d23 )**: [React Refresh] support typescript namespace syntax ([#22621](react/react#22621)) //<irinakk>// - **[0ddd69d](react/react@0ddd69d12 )**: Throw on hydration mismatch and force client rendering if boundary hasn't suspended within concurrent root ([#22629](react/react#22629)) //<salazarm>// - **[c3f34e4](react/react@c3f34e4be )**: [email protected] //<Dan Abramov>// - **[827021c](react/react@827021c4e )**: Changelog for [email protected] //<Dan Abramov>// - **[8ca3f56](react/react@8ca3f567b )**: Fix module-boundary wrappers ([#22688](react/react#22688)) //<Brian Vaughn>// - **[1bf6deb](react/react@1bf6deb86 )**: Renamed packages/react-devtools-scheduling-profiler to packages/react-devtools-timeline ([#22691](react/react#22691)) //<Brian Vaughn>// - **[51c558a](react/react@51c558aeb )**: Rename (some) "scheduling profiler" references to "timeline" ([#22690](react/react#22690)) //<Brian Vaughn>// - **[00ced1e](react/react@00ced1e2b )**: Fix useId in strict mode ([#22681](react/react#22681)) //<Andrew Clark>// - **[5cccacd](react/react@5cccacd13 )**: Upgrade useId to alpha channel ([#22674](react/react#22674)) //<Andrew Clark>// - **[75f3dde](react/react@75f3ddebf )**: Remove experimental useOpaqueIdentifier API ([#22672](react/react#22672)) //<Andrew Clark>// - **[8c4a05b](react/react@8c4a05b8f )**: Remove flow pragma comment from module registration start/stop templates ([#22670](react/react#22670)) //<Brian Vaughn>// - **[ebf9ae8](react/react@ebf9ae857 )**: useId ([#22644](react/react#22644)) //<Andrew Clark>// - **[a0d991f](react/react@a0d991fe6 )**: Re-land #22292 (remove uMS from open source build) ([#22664](react/react#22664)) //<Andrew Clark>// - **[6bce035](react/react@6bce0355c )**: Upgrade useSyncExternalStore to alpha channel ([#22662](react/react#22662)) //<Andrew Clark>// - **[7034408](react/react@7034408ff )**: Follow-up improvements to error code extraction infra ([#22516](react/react#22516)) //<Andrew Clark>// - **[90e5d36](react/react@90e5d3638 )**: chore: fix comment typo ([#22615](react/react#22615)) //<btea>// - **[3c4c1c4](react/react@3c4c1c470 )**: Remove warning for dangling passive effects ([#22609](react/react#22609)) //<Andrew Clark>// - **[d5b6b4b](react/react@d5b6b4b86 )**: Expand act warning to cover all APIs that might schedule React work ([#22607](react/react#22607)) //<Andrew Clark>// - **[fa9bea0](react/react@fa9bea0c4 )**: Initial implementation of cache cleanup ([#22510](react/react#22510)) //<Joseph Savona>// - **[0e8a5af](react/react@0e8a5aff3 )**: Scheduling Profiler: Add marks for component effects (mount and unmount) ([#22578](react/react#22578)) //<Brian Vaughn>// - **[4ba2057](react/react@4ba20579d )**: Scheduling Profiler: De-emphasize React internal frames ([#22588](react/react#22588)) //<Brian Vaughn>// - **[cdb8a1d](react/react@cdb8a1d19 )**: [Fizz] Add option to inject bootstrapping script tags after the shell is injected ([#22594](react/react#22594)) //<Sebastian Markbåge>// - **[34e4c97](react/react@34e4c9756 )**: Clear extra nodes if there's a hydration mismatch within a suspense boundary ([#22592](react/react#22592)) //<Sebastian Markbåge>// - **[02f4115](react/react@02f411578 )**: Upgrade useInsertionEffect to stable ([#22589](react/react#22589)) //<Andrew Clark>// - **[2af4a79](react/react@2af4a7933 )**: Hydrate using SuspenseComponent as the parent ([#22582](react/react#22582)) //<Sebastian Markbåge>// - **[b1acff0](react/react@b1acff0cc )**: Enable cache in test renderer ([#22580](react/react#22580)) //<Joseph Savona>// - **[996da67](react/react@996da67b2 )**: Replace global `jest` heuristic with `IS_REACT_ACT_ENVIRONMENT` ([#22562](react/react#22562)) //<Andrew Clark>// - **[163e81c](react/react@163e81c1f )**: Support disabling spurious act warnings with a global environment flag ([#22561](react/react#22561)) //<Andrew Clark>// - **[23b7dfe](react/react@23b7dfeff )**: Enable scheduling profiler for RN FB profiling builds ([#22566](react/react#22566)) //<Brian Vaughn>// - **[61455a2](react/react@61455a25b )**: Enable experimental Cache API in www TestRenderer ([#22554](react/react#22554)) //<Joseph Savona>// - **[7142d11](react/react@7142d110b )**: Bugfix: Nested useOpaqueIdentifier references ([#22553](react/react#22553)) //<Andrew Clark>// - **[1e247ff](react/react@1e247ff89 )**: Enabled scheduling profiler marks for React Native FB target ([#22544](react/react#22544)) //<Brian Vaughn>// - **[c16b005](react/react@c16b005f2 )**: Update test and stack frame code to support newer V8 stack formats ([#22477](react/react#22477)) //<Brian Vaughn>// - **[55d7500](react/react@55d75005b )**: duplicate value in variable ([#22390](react/react#22390)) //<BIKI DAS>// Changelog: [General][Changed] - React Native sync for revisions afcb9cd...c0c71a8 jest_e2e[run_all_tests] Reviewed By: yungsters Differential Revision: D32395873 fbshipit-source-id: 3afd158f167b1eedcc244e29aba1a2c502d3c9d9
* Handle render phase updates explicitly We fire a warning in development if a component is updated during the render phase (with the exception of local hook updates, which have their own defined behavior). Because it's not a supported React pattern, we don't have that many tests that trigger this path. But it is meant to have reasonable semantics when it does happen, so that if it accidentally ships to production, the app doesn't crash unnecessarily. The behavior is not super well-defined, though. There are also some _internal_ React implementation details that intentionally to rely on this behavior. Most prominently, selective hydration and useOpaqueIdentifier. I need to tweak the behavior of render phase updates slightly as part of a fix for useOpaqueIdentifier. This shouldn't cause a user-facing change in behavior outside of useOpaqueIdentifier, but it does require that we explicitly model render phase updates. * Bugfix: Nested useOpaqueIdentifier calls Fixes an issue where multiple useOpaqueIdentifier hooks are upgraded to client ids within the same render. The way the upgrade works is that useOpaqueIdentifier schedules a render phase update then throws an error to trigger React's error recovery mechanism. The normal error recovery mechanism is designed for errors that occur as a result of interleaved mutations, so we usually only retry a single time, synchronously, before giving up. useOpaqueIdentifier is different because the error its throws when upgrading is not caused by an interleaved mutation. Rather, it happens when an ID is referenced for the first time inside a client-rendered tree (i.e. sommething that wasn't part of the initial server render). The fact that it relies on the error recovery mechanism is an implementation detail. And a single recovery attempt may be insufficient. For example, if a parent and a child component may reference different ids, and both are mounted as a result of the same client update, that will trigger two separate error recovery attempts. Because render phase updates are not allowed when triggered from userspace — we log a warning in developement to prevent them — we can assume that if something does update during the render phase, it is one of our "legit" implementation details like useOpaqueIdentifier. So we can keep retrying until we succeed — up to a limit, to protect against inifite loops. I chose 50 since that's the limit we use for commit phase updates.
* Handle render phase updates explicitly We fire a warning in development if a component is updated during the render phase (with the exception of local hook updates, which have their own defined behavior). Because it's not a supported React pattern, we don't have that many tests that trigger this path. But it is meant to have reasonable semantics when it does happen, so that if it accidentally ships to production, the app doesn't crash unnecessarily. The behavior is not super well-defined, though. There are also some _internal_ React implementation details that intentionally to rely on this behavior. Most prominently, selective hydration and useOpaqueIdentifier. I need to tweak the behavior of render phase updates slightly as part of a fix for useOpaqueIdentifier. This shouldn't cause a user-facing change in behavior outside of useOpaqueIdentifier, but it does require that we explicitly model render phase updates. * Bugfix: Nested useOpaqueIdentifier calls Fixes an issue where multiple useOpaqueIdentifier hooks are upgraded to client ids within the same render. The way the upgrade works is that useOpaqueIdentifier schedules a render phase update then throws an error to trigger React's error recovery mechanism. The normal error recovery mechanism is designed for errors that occur as a result of interleaved mutations, so we usually only retry a single time, synchronously, before giving up. useOpaqueIdentifier is different because the error its throws when upgrading is not caused by an interleaved mutation. Rather, it happens when an ID is referenced for the first time inside a client-rendered tree (i.e. sommething that wasn't part of the initial server render). The fact that it relies on the error recovery mechanism is an implementation detail. And a single recovery attempt may be insufficient. For example, if a parent and a child component may reference different ids, and both are mounted as a result of the same client update, that will trigger two separate error recovery attempts. Because render phase updates are not allowed when triggered from userspace — we log a warning in developement to prevent them — we can assume that if something does update during the render phase, it is one of our "legit" implementation details like useOpaqueIdentifier. So we can keep retrying until we succeed — up to a limit, to protect against inifite loops. I chose 50 since that's the limit we use for commit phase updates.
* Handle render phase updates explicitly We fire a warning in development if a component is updated during the render phase (with the exception of local hook updates, which have their own defined behavior). Because it's not a supported React pattern, we don't have that many tests that trigger this path. But it is meant to have reasonable semantics when it does happen, so that if it accidentally ships to production, the app doesn't crash unnecessarily. The behavior is not super well-defined, though. There are also some _internal_ React implementation details that intentionally to rely on this behavior. Most prominently, selective hydration and useOpaqueIdentifier. I need to tweak the behavior of render phase updates slightly as part of a fix for useOpaqueIdentifier. This shouldn't cause a user-facing change in behavior outside of useOpaqueIdentifier, but it does require that we explicitly model render phase updates. * Bugfix: Nested useOpaqueIdentifier calls Fixes an issue where multiple useOpaqueIdentifier hooks are upgraded to client ids within the same render. The way the upgrade works is that useOpaqueIdentifier schedules a render phase update then throws an error to trigger React's error recovery mechanism. The normal error recovery mechanism is designed for errors that occur as a result of interleaved mutations, so we usually only retry a single time, synchronously, before giving up. useOpaqueIdentifier is different because the error its throws when upgrading is not caused by an interleaved mutation. Rather, it happens when an ID is referenced for the first time inside a client-rendered tree (i.e. sommething that wasn't part of the initial server render). The fact that it relies on the error recovery mechanism is an implementation detail. And a single recovery attempt may be insufficient. For example, if a parent and a child component may reference different ids, and both are mounted as a result of the same client update, that will trigger two separate error recovery attempts. Because render phase updates are not allowed when triggered from userspace — we log a warning in developement to prevent them — we can assume that if something does update during the render phase, it is one of our "legit" implementation details like useOpaqueIdentifier. So we can keep retrying until we succeed — up to a limit, to protect against inifite loops. I chose 50 since that's the limit we use for commit phase updates.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.