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

Ensure updating Context.Consumer inside suspended Suspense component #21414

Closed

Conversation

okmttdhr
Copy link
Contributor

@okmttdhr okmttdhr commented May 3, 2021

Summary

Ensure updating Context.Consumer inside suspended Suspense component when context updates. Please see #19701 for details of this bug.

Fixes #19701

Related #14717 #16346 | #20890 | #18796

Test Plan

Run yarn test --watch ReactSuspense-test.internal.

@facebook-github-bot
Copy link

Hi @okmttdhr!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@sizebot
Copy link

sizebot commented May 3, 2021

Comparing: 51947a1...df5a90b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js +0.03% 129.66 kB 129.70 kB +0.04% 41.57 kB 41.59 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +0.03% 134.80 kB 134.84 kB +0.03% 43.09 kB 43.10 kB
facebook-www/ReactDOM-prod.classic.js +0.06% 428.08 kB 428.34 kB +0.06% 78.65 kB 78.70 kB
facebook-www/ReactDOM-prod.modern.js +0.06% 417.80 kB 418.06 kB +0.06% 77.19 kB 77.24 kB
facebook-www/ReactDOMForked-prod.classic.js +0.06% 428.08 kB 428.34 kB +0.06% 78.66 kB 78.70 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against df5a90b

@okmttdhr okmttdhr force-pushed the fix/context-consumer-in-suspense branch from e03c92e to fb36d98 Compare May 3, 2021 14:11
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

1 similar comment
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@okmttdhr okmttdhr changed the title Update Context.Consumer inside suspended Suspense component Ensure updating Context.Consumer inside suspended Suspense component May 3, 2021
@okmttdhr okmttdhr marked this pull request as draft May 5, 2021 06:33
@okmttdhr okmttdhr force-pushed the fix/context-consumer-in-suspense branch from aea2754 to 0c94041 Compare May 8, 2021 05:36
@okmttdhr okmttdhr requested a review from gaearon May 8, 2021 05:39
@okmttdhr okmttdhr force-pushed the fix/context-consumer-in-suspense branch from 0c94041 to b45ac12 Compare May 8, 2021 06:10
@okmttdhr okmttdhr force-pushed the fix/context-consumer-in-suspense branch from b45ac12 to ed58992 Compare May 9, 2021 05:29
@okmttdhr okmttdhr marked this pull request as ready for review May 9, 2021 05:45
@stale
Copy link

stale bot commented Jan 9, 2022

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

@stale stale bot added the Resolution: Stale Automatically closed due to inactivity label Jan 9, 2022
@okmttdhr
Copy link
Contributor Author

okmttdhr commented Jan 9, 2022

bump

@stale stale bot removed the Resolution: Stale Automatically closed due to inactivity label Jan 9, 2022
@gaearon
Copy link
Collaborator

gaearon commented Jan 11, 2022

Another possible fix: #23095. Not sure what's better.

@okmttdhr okmttdhr changed the base branch from master to main January 17, 2022 02:15
@okmttdhr okmttdhr force-pushed the fix/context-consumer-in-suspense branch 4 times, most recently from e3c5596 to ba7d2ed Compare January 17, 2022 02:33
@okmttdhr okmttdhr force-pushed the fix/context-consumer-in-suspense branch from ba7d2ed to 3a1aa3e Compare January 17, 2022 02:42
…'s consistent

Revert "Update only parents that may be inconsistent"

This reverts commit 3a1aa3e.
@okmttdhr
Copy link
Contributor Author

okmttdhr commented Jan 17, 2022

Another possible fix: #23095. Not sure what's better.

Let me briefly summarize for my understanding.

First of all, this PR is an approach to "directly" update nodes that can be inconsistent only when it knows that there is Consumer in SuspenseComponent. There is a possibility of traverse outside of the propagation root, but if it is consistent, it will break; anyway, so I don't see a problem.

But this PR only fixes the case where the bug in #19701 occurs.
For example, as you mentioned in #23095, it probably won't fix the cases other than #19701 where context fails to propagate (not sure if that exists).

I understood #23095 to be an approach that always traverse up to the propagation root, even if it looks consistent.
From the model perspective, "traverse upwards (past the propagation root) should not be necessary to do", so #23095 update the childLanes only up to the propagation root.
However, I understood that you are worrying about the case where the assumption itself is wrong, as it says;

My concern isn't so much Consumer API but the flaw in modeling. The assumption seems fundamentally flawed and I'm worried how else it might bite us.

@gaearon
Copy link
Collaborator

gaearon commented Jan 19, 2022

We went with #23095.

@gaearon gaearon closed this Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Context.Consumer inside Suspense does not receive context updates while suspended
4 participants