Skip to content

Failing test related to usage of Suspense and Context in memoized component#18572

Closed
Tsdevendra1 wants to merge 4 commits into
react:masterfrom
Tsdevendra1:failingtestforsuspense
Closed

Failing test related to usage of Suspense and Context in memoized component#18572
Tsdevendra1 wants to merge 4 commits into
react:masterfrom
Tsdevendra1:failingtestforsuspense

Conversation

@Tsdevendra1

Copy link
Copy Markdown
Contributor

Failing test as requested related to #17356.

This is a failing test which shows that when useContext and throwing a promise are used in a memoized component, it fails to update after the promise has resolved.

@codesandbox-ci

codesandbox-ci Bot commented Apr 10, 2020

Copy link
Copy Markdown

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 488ae4c:

Sandbox Source
optimistic-mcclintock-54s0p Configuration

@sizebot

sizebot commented Apr 10, 2020

Copy link
Copy Markdown

No significant bundle size changes to report.

Size changes (stable)

Generated by 🚫 dangerJS against 488ae4c

@sizebot

sizebot commented Apr 10, 2020

Copy link
Copy Markdown

No significant bundle size changes to report.

Size changes (experimental)

Generated by 🚫 dangerJS against 488ae4c

@acdlite

acdlite commented Apr 10, 2020

Copy link
Copy Markdown
Collaborator

Ah nice test case! Confirmed this is a bug in "legacy" mode Suspense. I checked, and the test passes in Concurrent Mode. (If you have a Concurrent Mode test case, please let me know.)

Note that technically, in outside of Concurrent Mode, we don't officially support suspending except for React.lazy. We'll fix this anyway though.

@acdlite

acdlite commented Apr 10, 2020

Copy link
Copy Markdown
Collaborator

It's essentially the same bug that we fixed here for classes:

https://github.com/facebook/react/blob/98d410f5005988644d01c9ec79b7181c3dd6c847/packages/react-reconciler/src/ReactFiberThrow.new.js#L260-L265

Need to decide on least bad way to fix it. My initial instinct is a special effect tag that prevents a bail out (ForceUpdate). It's a hack but it works.

Then we would add that check to this condition here, to prevent us from setting didReceiveUpdate to false.

https://github.com/facebook/react/blob/98d410f5005988644d01c9ec79b7181c3dd6c847/packages/react-reconciler/src/ReactFiberBeginWork.new.js#L517-L522

@Tsdevendra1

Copy link
Copy Markdown
Contributor Author

Hi @acdlite, I've added a test case for the concurrent mode which passes. I'll have a go at implementing the solution you outlined and getting back to you.

@Tsdevendra1

Copy link
Copy Markdown
Contributor Author

I think I'm a bit stuck on this or maybe I didn't understand what you suggested properly. When I try to enqueue a ForceUpdate, the updateQueue is null for the memo fiber (which according to this: https://github.com/facebook/react/blob/32bb44c80ac64b3c96fa9e03b6ecb6dce6a0de6e/packages/react-reconciler/src/ReactUpdateQueue.new.js#L219 is because the fiber has been unmounted). But this means nothing gets added to the update queue and as a result I can't differentiate that fiber when updateSimpleMemoComponent is called after the promise is resolved. Am I going about this the wrong way?

On a separate note, there seem to be .old and .new versions of some files, should I be modifying both or just one? I asked because when I build my local react using yarn build react/index,react-dom/index,scheduler --type=NODE (suggested here) it seems to be using the .old version of the files, I'm not sure how to use the .new version of the files.

@gaearon

gaearon commented Apr 21, 2020

Copy link
Copy Markdown
Collaborator

If you don't plan to keep working on this, would you mind keeping the failing test open as a reminder?

@gaearon

gaearon commented Jun 30, 2020

Copy link
Copy Markdown
Collaborator

#19216

@stale

stale Bot commented Oct 4, 2020

Copy link
Copy Markdown

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 Oct 4, 2020
@eps1lon

eps1lon commented Oct 4, 2020

Copy link
Copy Markdown
Collaborator

Superseded by #19216.

@eps1lon eps1lon closed this Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Resolution: Stale Automatically closed due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants