Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Fix selector issue with early rendering mode #1566

Closed

Conversation

drarmstr
Copy link
Contributor

Summary:
Normally when a dependency resolves it notifies downstream components to re-render and this is sufficient. While it is still pending, the selector returns this promise; subsequent renders while pending will re-use the same loadable using getExecutionInfoOfInProgressExecution().

However, there is a corner case we have to notify components that an async selector has resolved, even if the selector does not have a "current pending execution":

  1. A component renders with this pending loadable.
  2. The upstream dependency resolves.
  3. While processing some other selector it reads this one, such as while traversing its dependencies. At this point it gets the new resolved value synchronously and clears the current execution ID. The component wasn't getting the value itself, though, so it still has the pending loadable.
  4. When wrapper handling the resolution executes the current execution id was cleared, so it will never notify the component of the new value.

I think this is only an issue with "early" rendering since the components read their value using the in-progress execution. Though, I'm not sure this is necessary with recoil_concurrent_support mode.

Differential Revision: D33737833

Summary:
Normally when a dependency resolves it notifies downstream components to re-render and this is sufficient.  While it is still pending, the selector returns this promise; subsequent renders while pending will re-use the same loadable using `getExecutionInfoOfInProgressExecution()`.

However, there is a corner case we have to notify components that an async selector has resolved, even if the selector does not have a "current pending execution":
 1) A component renders with this pending loadable.
 2) The upstream dependency resolves.
 3) While processing some other selector it reads this one, such as while traversing its dependencies.  At this point it gets the new resolved value synchronously and clears the current execution ID.  The component wasn't getting the value itself, though, so it still has the pending loadable.
4) When wrapper handling the resolution executes the current execution id was cleared, so it will never notify the component of the new value.

I think this is only an issue with "early" rendering since the components read their value using the in-progress execution.  Though, I'm not sure this is necessary with `recoil_concurrent_support` mode.

Differential Revision: D33737833

fbshipit-source-id: 51934954bd59aece29abfe2fa9bc033b7fda805a
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported labels Jan 24, 2022
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D33737833

drarmstr added a commit to drarmstr/Recoil that referenced this pull request Jan 25, 2022
Summary:
Pull Request resolved: facebookexperimental#1566

Normally when a dependency resolves it notifies downstream components to re-render and this is sufficient.  While it is still pending, the selector returns this promise; subsequent renders while pending will re-use the same loadable using `getExecutionInfoOfInProgressExecution()`.

However, there is a corner case we have to notify components that an async selector has resolved, even if the selector does not have a "current pending execution":
 1) A component renders with this pending loadable.
 2) The upstream dependency resolves.
 3) While processing some other selector it reads this one, such as while traversing its dependencies.  At this point it gets the new resolved value synchronously and clears the current execution ID.  The component wasn't getting the value itself, though, so it still has the pending loadable.
4) When wrapper handling the resolution executes the current execution id was cleared, so it will never notify the component of the new value.

I think this is only an issue with "early" rendering since the components read their value using the in-progress execution.  Though, I'm not sure this is necessary with `recoil_concurrent_support` mode.

Differential Revision: https://www.internalfb.com/diff/D33737833?entry_point=27

fbshipit-source-id: 13998cfe9e3ad31152e10a4a68027f60255316f9
drarmstr added a commit to drarmstr/Recoil that referenced this pull request Jan 25, 2022
Summary:
Pull Request resolved: facebookexperimental#1566

Normally when a dependency resolves it notifies downstream components to re-render and this is sufficient.  While it is still pending, the selector returns this promise; subsequent renders while pending will re-use the same loadable using `getExecutionInfoOfInProgressExecution()`.

However, there is a corner case we have to notify components that an async selector has resolved, even if the selector does not have a "current pending execution":
 1) A component renders with this pending loadable.
 2) The upstream dependency resolves.
 3) While processing some other selector it reads this one, such as while traversing its dependencies.  At this point it gets the new resolved value synchronously and clears the current execution ID.  The component wasn't getting the value itself, though, so it still has the pending loadable.
4) When wrapper handling the resolution executes the current execution id was cleared, so it will never notify the component of the new value.

I think this is only an issue with "early" rendering since the components read their value using the in-progress execution.  Though, I'm not sure this is necessary with `recoil_concurrent_support` mode.

Differential Revision: https://www.internalfb.com/diff/D33737833?entry_point=27

fbshipit-source-id: f5b1c567ce43458517e672aabb4f78786c3600b8
@drarmstr drarmstr self-assigned this Jan 25, 2022
@drarmstr drarmstr added the bug Something isn't working label Jan 25, 2022
drarmstr added a commit to drarmstr/Recoil that referenced this pull request Jan 25, 2022
Summary:
Pull Request resolved: facebookexperimental#1566

Normally when a dependency resolves it notifies downstream components to re-render and this is sufficient.  While it is still pending, the selector returns this promise; subsequent renders while pending will re-use the same loadable using `getExecutionInfoOfInProgressExecution()`.

However, there is a corner case we have to notify components that an async selector has resolved, even if the selector does not have a "current pending execution":
 1) A component renders with this pending loadable.
 2) The upstream dependency resolves.
 3) While processing some other selector it reads this one, such as while traversing its dependencies.  At this point it gets the new resolved value synchronously and clears the current execution ID.  The component wasn't getting the value itself, though, so it still has the pending loadable.
4) When wrapper handling the resolution executes the current execution id was cleared, so it will never notify the component of the new value.

I think this is only an issue with "early" rendering since the components read their value using the in-progress execution.  Though, I'm not sure this is necessary with `recoil_concurrent_support` mode.

Differential Revision: https://www.internalfb.com/diff/D33737833?entry_point=27

fbshipit-source-id: f2880ca63d50b5a4cfdc360175b3ed1b10f269ef
drarmstr added a commit to drarmstr/Recoil that referenced this pull request Jan 26, 2022
Summary:
Pull Request resolved: facebookexperimental#1566

Normally when a dependency resolves it notifies downstream components to re-render and this is sufficient.  While it is still pending, the selector returns this promise; subsequent renders while pending will re-use the same loadable using `getExecutionInfoOfInProgressExecution()`.

However, there is a corner case we have to notify components that an async selector has resolved, even if the selector does not have a "current pending execution":
 1) A component renders with this pending loadable.
 2) The upstream dependency resolves.
 3) While processing some other selector it reads this one, such as while traversing its dependencies.  At this point it gets the new resolved value synchronously and clears the current execution ID.  The component wasn't getting the value itself, though, so it still has the pending loadable.
4) When wrapper handling the resolution executes the current execution id was cleared, so it will never notify the component of the new value.

I think this is only an issue with "early" rendering since the components read their value using the in-progress execution.  Though, I'm not sure this is necessary with `recoil_concurrent_support` mode.

Differential Revision: https://www.internalfb.com/diff/D33737833?entry_point=27

fbshipit-source-id: c8ba67330f10736de0be687f1108827186041797
@drarmstr drarmstr deleted the export-D33737833 branch January 29, 2022 07:04
AlexGuz23 pushed a commit to AlexGuz23/Recoil that referenced this pull request Nov 3, 2022
Summary:
Pull Request resolved: facebookexperimental/Recoil#1566

Normally when a dependency resolves it notifies downstream components to re-render and this is sufficient.  While it is still pending, the selector returns this promise; subsequent renders while pending will re-use the same loadable using `getExecutionInfoOfInProgressExecution()`.

However, there is a corner case we have to notify components that an async selector has resolved, even if the selector does not have a "current pending execution":
 1) A component renders with this pending loadable.
 2) The upstream dependency resolves.
 3) While processing some other selector it reads this one, such as while traversing its dependencies.  At this point it gets the new resolved value synchronously and clears the current execution ID.  The component wasn't getting the value itself, though, so it still has the pending loadable.
4) When wrapper handling the resolution executes the current execution id was cleared, so it will never notify the component of the new value.

I think this is only an issue with "early" rendering since the components read their value using the in-progress execution.  Though, I'm not sure this is necessary with `recoil_concurrent_support` mode.

Reviewed By: davidmccabe

Differential Revision: D33737833

fbshipit-source-id: ac71f5ac4ea72543f384421054838f0f4c88a9c3
snipershooter0701 pushed a commit to snipershooter0701/Recoil that referenced this pull request Mar 5, 2023
Summary:
Pull Request resolved: facebookexperimental/Recoil#1566

Normally when a dependency resolves it notifies downstream components to re-render and this is sufficient.  While it is still pending, the selector returns this promise; subsequent renders while pending will re-use the same loadable using `getExecutionInfoOfInProgressExecution()`.

However, there is a corner case we have to notify components that an async selector has resolved, even if the selector does not have a "current pending execution":
 1) A component renders with this pending loadable.
 2) The upstream dependency resolves.
 3) While processing some other selector it reads this one, such as while traversing its dependencies.  At this point it gets the new resolved value synchronously and clears the current execution ID.  The component wasn't getting the value itself, though, so it still has the pending loadable.
4) When wrapper handling the resolution executes the current execution id was cleared, so it will never notify the component of the new value.

I think this is only an issue with "early" rendering since the components read their value using the in-progress execution.  Though, I'm not sure this is necessary with `recoil_concurrent_support` mode.

Reviewed By: davidmccabe

Differential Revision: D33737833

fbshipit-source-id: ac71f5ac4ea72543f384421054838f0f4c88a9c3
eagle2722 added a commit to eagle2722/Recoil that referenced this pull request Sep 21, 2024
Summary:
Pull Request resolved: facebookexperimental/Recoil#1566

Normally when a dependency resolves it notifies downstream components to re-render and this is sufficient.  While it is still pending, the selector returns this promise; subsequent renders while pending will re-use the same loadable using `getExecutionInfoOfInProgressExecution()`.

However, there is a corner case we have to notify components that an async selector has resolved, even if the selector does not have a "current pending execution":
 1) A component renders with this pending loadable.
 2) The upstream dependency resolves.
 3) While processing some other selector it reads this one, such as while traversing its dependencies.  At this point it gets the new resolved value synchronously and clears the current execution ID.  The component wasn't getting the value itself, though, so it still has the pending loadable.
4) When wrapper handling the resolution executes the current execution id was cleared, so it will never notify the component of the new value.

I think this is only an issue with "early" rendering since the components read their value using the in-progress execution.  Though, I'm not sure this is necessary with `recoil_concurrent_support` mode.

Reviewed By: davidmccabe

Differential Revision: D33737833

fbshipit-source-id: ac71f5ac4ea72543f384421054838f0f4c88a9c3
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants