Skip to content
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

Fix useMutableSource tearing bug #18912

Merged
merged 2 commits into from May 13, 2020
Merged

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented May 13, 2020

If a source is mutated after initial read but before subscription is set up, it should still entangle all pending mutations even if snapshot of new subscription happens to match.

Test case illustrates how not doing this can lead to tearing.

The fix is to move the entanglement call outside of the block that checks if the snapshot has changed.

If a source is mutated after initial read but before subscription is set
up, it should still entangle all pending mutations even if snapshot of
new subscription happens to match.

Test case illustrates how not doing this can lead to tearing.
Fix is to move the entanglement call outside of the block that checks
if the snapshot has changed.
@acdlite acdlite requested a review from bvaughn May 13, 2020 19:01
@facebook-github-bot facebook-github-bot added React Core Team Opened by a member of the React Core Team CLA Signed labels May 13, 2020
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 43ce30b:

Sandbox Source
gracious-ritchie-6hofe Configuration

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c3c4c3f:

Sandbox Source
sweet-dubinsky-bqbis Configuration

@sizebot
Copy link

sizebot commented May 13, 2020

No significant bundle size changes to report.

Size changes (stable)

Generated by 🚫 dangerJS against c3c4c3f

@sizebot
Copy link

sizebot commented May 13, 2020

No significant bundle size changes to report.

Size changes (experimental)

Generated by 🚫 dangerJS against c3c4c3f

Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

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

This looks like an improvement!

Correct me if I'm wrong though, but this tearing case would still be possible for any source where version is not an auto-incremented value (e.g. window.location, maybe even Redux stores).

// There is no mechanism currently to associate these updates though,
// so for now we fall back to synchronously flushing all pending updates.
// TODO: Improve this later.
markRootExpiredAtTime(root, getLastPendingExpirationTime(root));
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, that's unfortunate. Even more deopts in old mode now.

@acdlite
Copy link
Collaborator Author

acdlite commented May 13, 2020

Correct me if I'm wrong though, but this tearing case would still be possible for any source where version is not an auto-incremented value (e.g. window.location, maybe even Redux stores).

Yeah sounds right to me. Something to think about.

@acdlite acdlite merged commit fdb6416 into facebook:master May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants