-
Notifications
You must be signed in to change notification settings - Fork 47.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Current Owner (and Cache) to an Async Dispatcher #28798
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook-github-bot
added
CLA Signed
React Core Team
Opened by a member of the React Core Team
labels
Apr 9, 2024
sebmarkbage
force-pushed
the
asynccurrentowner
branch
2 times, most recently
from
April 9, 2024 18:51
0e3f7a6
to
c49a5df
Compare
Just landed #28797 so this will need a quick rebase |
sebmarkbage
force-pushed
the
asynccurrentowner
branch
from
April 9, 2024 20:51
bd31035
to
2244c3e
Compare
T: null | BatchConfigTransition, // ReactCurrentBatchConfig for Transitions | ||
|
||
// DEV-only-ish | ||
owner: null | Fiber, // ReactCurrentOwner is Fiber on the Client, null in Fizz. Flight uses SharedStateServer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need this I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? It's replaced by A.getOwner()
gnoff
approved these changes
Apr 17, 2024
Basically always but we currently don't actually need it for prod on the client.
This means that usage internal to the reconciler can refer to it directly without going through the dispatcher.
This will later use AsyncLocalStorage to track this just like the cache.
We need to be careful about only getting it in branches that has the dispatcher activated and if the dispatcher is activate.
sebmarkbage
force-pushed
the
asynccurrentowner
branch
from
April 23, 2024 00:36
2244c3e
to
fac727f
Compare
gnoff
force-pushed
the
asynccurrentowner
branch
from
April 25, 2024 17:34
ffa4ba4
to
fac727f
Compare
github-actions bot
pushed a commit
that referenced
this pull request
Apr 25, 2024
…28912) Rebasing and landing #28798 This PR was approved already but held back to give time for the sync. Rebased and landing here without pushing to seb's remote to avoid possibility of lost updates --------- Co-authored-by: Sebastian Markbage <sebastian@calyptus.eu> DiffTrain build for commit 94eed63.
github-actions bot
pushed a commit
that referenced
this pull request
Apr 25, 2024
…28912) Rebasing and landing #28798 This PR was approved already but held back to give time for the sync. Rebased and landing here without pushing to seb's remote to avoid possibility of lost updates --------- Co-authored-by: Sebastian Markbage <sebastian@calyptus.eu> DiffTrain build for [94eed63](94eed63)
landed in #28912 |
sebmarkbage
added a commit
that referenced
this pull request
May 3, 2024
Stacked on #28798. Add another AsyncLocalStorage to the FlightServerConfig. This context tracks data on a per component level. Currently the only thing we track is the owner in DEV. AsyncLocalStorage around each component comes with a performance cost so we only do it DEV. It's not generally a particularly safe operation because you can't necessarily associate side-effects with a component based on execution scope. It can be a lazy initializer or cache():ed code etc. We also don't support string refs anymore for a reason. However, it's good enough for optional dev only information like the owner.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current Owner inside an Async Component will need to be tracked using AsyncLocalStorage. This is similar to how
cache()
works.Sooner or later we'll have to start tracking AsyncContext in the isomorphic package because
startTransition(async)
needs it. Since the transition config needs to be tracked asynchronously too. However, we can reasonably only do that once it's actually shipping in all browsers pretty much. I.e. not soon.The way we do this with
cache()
(and Float in the DOM package) is by delegating it to a dispatcher that can be alive for longer and then within that dispatcher use an environment specific context to track that renderer's internal state.This renames the CacheDispatcher to the more generic AsyncDispatcher and add a
getOwner
method on it. Then we track the actual state of the owner inside of each renderer. This doesn't yet track the owner asynchronously in Flight but I'll do that part in a follow up.