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

Land Lanes implementation in old fork #19108

Merged
merged 5 commits into from
Jun 12, 2020
Merged

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Jun 9, 2020

Replaces the old reconciler fork with the contents of the new reconciler fork.

There are still separate "old" and "new" forks, but they are now identical. We will continue to use the fork infra to land risky changes and refactors.

Most of the changes were automated using a new command, yarn replace-fork. I put the manual changes (removing dead branches, cleaning up tests, etc) into a separate commit.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jun 9, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 9, 2020

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 ada036b:

Sandbox Source
competent-kare-fqe69 Configuration

// category: "Possible Errors",
// recommended: true,
// url: "https://eslint.org/docs/rules/no-extra-semi"
// },
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops, copypasta. Will delete.

@sizebot
Copy link

sizebot commented Jun 9, 2020

Details of bundled changes.

Comparing: 7f28234...ada036b

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js +1.4% +1.8% 910.49 KB 923.13 KB 206.22 KB 209.84 KB NODE_DEV
ReactDOMForked-prod.js -0.0% -0.0% 395.73 KB 395.63 KB 73.43 KB 73.4 KB FB_WWW_PROD
react-dom-server.node.development.js 0.0% -0.0% 138.24 KB 138.24 KB 36.58 KB 36.58 KB NODE_DEV
react-dom.production.min.js 🔺+0.4% 🔺+2.4% 126.24 KB 126.77 KB 39.38 KB 40.33 KB NODE_PROD
ReactDOMForked-profiling.js -0.0% -0.0% 406.27 KB 406.17 KB 75.19 KB 75.16 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 144.37 KB 144.37 KB 36.78 KB 36.78 KB UMD_DEV
react-dom-server.node.production.min.js 0.0% -0.0% 20.68 KB 20.68 KB 7.66 KB 7.66 KB NODE_PROD
react-dom-test-utils.production.min.js 0.0% -0.0% 13.18 KB 13.18 KB 4.9 KB 4.9 KB UMD_PROD
ReactDOMTesting-dev.js +1.1% +1.5% 943.01 KB 953.05 KB 211.1 KB 214.2 KB FB_WWW_DEV
react-dom-test-utils.development.js 0.0% -0.0% 70.09 KB 70.09 KB 19.6 KB 19.6 KB NODE_DEV
ReactDOMTesting-prod.js -0.4% 🔺+1.4% 396.51 KB 394.89 KB 73.48 KB 74.51 KB FB_WWW_PROD
react-dom-unstable-fizz.node.development.js 0.0% -0.1% 5.61 KB 5.61 KB 1.87 KB 1.86 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 13.06 KB 13.06 KB 4.81 KB 4.8 KB NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 5.36 KB 5.36 KB 1.81 KB 1.8 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% -0.3% 1.17 KB 1.17 KB 668 B 666 B NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.4% 1.2 KB 1.2 KB 707 B 704 B UMD_PROD
ReactTestUtils-dev.js -0.1% -0.1% 51.33 KB 51.27 KB 14.39 KB 14.38 KB FB_WWW_DEV
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 4.87 KB 4.87 KB 1.71 KB 1.7 KB NODE_DEV
react-dom.development.js +1.4% +1.8% 956.38 KB 970.01 KB 208.81 KB 212.59 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1.01 KB 1.01 KB 617 B 615 B NODE_PROD
react-dom.production.min.js 🔺+0.4% 🔺+2.1% 126.04 KB 126.55 KB 40.35 KB 41.2 KB UMD_PROD
react-dom.profiling.min.js +0.3% +2.0% 130.15 KB 130.51 KB 41.57 KB 42.38 KB UMD_PROFILING
ReactDOMForked-dev.js -0.0% -0.0% 972.65 KB 972.45 KB 217.2 KB 217.13 KB FB_WWW_DEV
react-dom.profiling.min.js +0.3% +2.1% 130.48 KB 130.9 KB 40.66 KB 41.51 KB NODE_PROFILING
react-dom-server.browser.production.min.js 0.0% -0.0% 20.34 KB 20.34 KB 7.52 KB 7.52 KB UMD_PROD
ReactDOM-dev.js +0.3% +1.0% 970.91 KB 973.59 KB 215.12 KB 217.24 KB FB_WWW_DEV
ReactDOM-prod.js -0.7% 🔺+1.4% 398.42 KB 395.83 KB 72.44 KB 73.42 KB FB_WWW_PROD
react-dom-server.browser.development.js 0.0% -0.0% 136.97 KB 136.97 KB 36.33 KB 36.33 KB NODE_DEV
ReactDOM-profiling.js -0.9% +1.1% 409.89 KB 406.36 KB 74.33 KB 75.18 KB FB_WWW_PROFILING
react-dom-server.browser.production.min.js 0.0% -0.0% 20.26 KB 20.26 KB 7.51 KB 7.51 KB NODE_PROD
ReactDOMServer-dev.js -0.0% -0.0% 142.56 KB 142.5 KB 36.28 KB 36.26 KB FB_WWW_DEV
ReactDOMServer-prod.js 0.0% -0.0% 46.58 KB 46.58 KB 10.9 KB 10.9 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% -0.0% 75.26 KB 75.26 KB 20.1 KB 20.1 KB UMD_DEV

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-prod.js -1.2% 🔺+2.5% 243.12 KB 240.23 KB 41.41 KB 42.46 KB FB_WWW_PROD
react-art.development.js +2.0% +2.7% 672.32 KB 685.91 KB 141.42 KB 145.19 KB UMD_DEV
react-art.production.min.js 🔺+0.5% 🔺+2.6% 111.75 KB 112.35 KB 33.88 KB 34.75 KB UMD_PROD
react-art.development.js +2.2% +3.0% 574.91 KB 587.52 KB 123.68 KB 127.4 KB NODE_DEV
react-art.production.min.js 🔺+0.8% 🔺+3.9% 76.7 KB 77.31 KB 23 KB 23.89 KB NODE_PROD
ReactART-dev.js +0.4% +1.7% 607.59 KB 610.27 KB 127.78 KB 130 KB FB_WWW_DEV

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +1.6% +2.4% 672.15 KB 682.71 KB 144.11 KB 147.51 KB RN_FB_DEV
ReactFabric-dev.js +1.5% +2.3% 653.39 KB 663.43 KB 139.67 KB 142.92 KB RN_FB_DEV
ReactNativeRenderer-dev.js +1.6% +2.4% 667.67 KB 678.25 KB 143.43 KB 146.84 KB RN_OSS_DEV
ReactFabric-prod.js -0.4% 🔺+2.6% 266.57 KB 265.59 KB 45.79 KB 46.98 KB RN_FB_PROD
ReactNativeRenderer-prod.js -0.6% 🔺+2.2% 273.5 KB 271.91 KB 47.22 KB 48.26 KB RN_OSS_PROD
ReactFabric-profiling.js -0.5% +2.3% 278.62 KB 277.12 KB 48.08 KB 49.2 KB RN_FB_PROFILING
ReactNativeRenderer-profiling.js -0.7% +1.9% 285.51 KB 283.42 KB 49.5 KB 50.46 KB RN_OSS_PROFILING
ReactNativeRenderer-prod.js -0.6% 🔺+2.2% 273.46 KB 271.87 KB 47.2 KB 48.25 KB RN_FB_PROD
ReactNativeRenderer-profiling.js -0.7% +1.9% 285.46 KB 283.37 KB 49.48 KB 50.44 KB RN_FB_PROFILING
ReactFabric-dev.js +1.6% +2.4% 648.91 KB 658.97 KB 138.95 KB 142.23 KB RN_OSS_DEV
ReactFabric-prod.js -0.4% 🔺+2.6% 266.61 KB 265.62 KB 45.81 KB 46.99 KB RN_OSS_PROD
ReactFabric-profiling.js -0.5% +2.3% 278.66 KB 277.16 KB 48.09 KB 49.22 KB RN_OSS_PROFILING

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js +2.3% +2.9% 588.79 KB 602.3 KB 122.85 KB 126.46 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.6% 🔺+3.3% 76.15 KB 76.6 KB 23.2 KB 23.97 KB UMD_PROD
react-test-renderer.development.js +2.2% +3.0% 561.3 KB 573.85 KB 121.36 KB 125 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.6% 🔺+3.3% 75.95 KB 76.42 KB 22.92 KB 23.67 KB NODE_PROD
ReactTestRenderer-dev.js +1.7% +2.7% 586.92 KB 597.12 KB 124.47 KB 127.86 KB FB_WWW_DEV
ReactTestRenderer-dev.js +1.8% +2.7% 579.47 KB 590.18 KB 124.23 KB 127.58 KB RN_FB_DEV

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +2.1% +2.8% 632.42 KB 645.42 KB 133.73 KB 137.53 KB NODE_DEV
react-reconciler-reflection.development.js 0.0% -0.0% 16.7 KB 16.7 KB 4.98 KB 4.98 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.6% 🔺+3.2% 86.54 KB 87.09 KB 25.8 KB 26.63 KB NODE_PROD
react-reconciler-reflection.production.min.js 0.0% -0.2% 2.81 KB 2.81 KB 1.16 KB 1.16 KB NODE_PROD

ReactDOM: size: 0.0%, gzip: -0.0%

Size changes (experimental)

Generated by 🚫 dangerJS against ada036b

@sizebot
Copy link

sizebot commented Jun 9, 2020

Details of bundled changes.

Comparing: 7f28234...ada036b

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js +1.4% +1.7% 880.36 KB 892.7 KB 200.81 KB 204.27 KB NODE_DEV
ReactDOMForked-prod.js -0.0% -0.0% 406.92 KB 406.82 KB 75.27 KB 75.23 KB FB_WWW_PROD
react-dom-server.node.development.js 0.0% -0.0% 136.73 KB 136.73 KB 36.37 KB 36.37 KB NODE_DEV
react-dom.production.min.js 🔺+0.3% 🔺+2.1% 121.96 KB 122.3 KB 38.22 KB 39.03 KB NODE_PROD
ReactDOMForked-profiling.js -0.0% -0.0% 417.52 KB 417.42 KB 77.04 KB 77.01 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 142.78 KB 142.78 KB 36.58 KB 36.58 KB UMD_DEV
react-dom-server.node.production.min.js 0.0% -0.0% 20.22 KB 20.22 KB 7.59 KB 7.59 KB NODE_PROD
react-dom-test-utils.production.min.js 0.0% -0.0% 13.17 KB 13.17 KB 4.89 KB 4.89 KB UMD_PROD
ReactDOMTesting-dev.js +1.0% +1.4% 968.8 KB 978.84 KB 216.7 KB 219.84 KB FB_WWW_DEV
react-dom-test-utils.development.js 0.0% -0.0% 70.08 KB 70.08 KB 19.59 KB 19.59 KB NODE_DEV
ReactDOMTesting-prod.js -0.4% 🔺+1.4% 408.37 KB 406.86 KB 75.38 KB 76.47 KB FB_WWW_PROD
react-dom-test-utils.production.min.js 0.0% -0.0% 13.05 KB 13.05 KB 4.8 KB 4.8 KB NODE_PROD
ReactTestUtils-dev.js -0.1% -0.1% 51.33 KB 51.27 KB 14.39 KB 14.37 KB FB_WWW_DEV
react-dom.development.js +1.4% +1.8% 924.93 KB 938.22 KB 203.34 KB 206.91 KB UMD_DEV
react-dom.production.min.js 🔺+0.3% 🔺+2.0% 121.84 KB 122.16 KB 39.14 KB 39.92 KB UMD_PROD
react-dom.profiling.min.js +0.2% +1.7% 125.81 KB 126.07 KB 40.4 KB 41.09 KB UMD_PROFILING
ReactDOMForked-dev.js -0.0% -0.0% 998.2 KB 998 KB 223.01 KB 222.95 KB FB_WWW_DEV
react-dom.profiling.min.js +0.3% +2.1% 126.07 KB 126.38 KB 39.42 KB 40.25 KB NODE_PROFILING
react-dom-server.browser.production.min.js 0.0% -0.0% 19.88 KB 19.88 KB 7.45 KB 7.44 KB UMD_PROD
ReactDOM-dev.js +0.3% +1.0% 996.46 KB 999.14 KB 220.85 KB 223.06 KB FB_WWW_DEV
ReactDOM-prod.js -0.6% 🔺+1.3% 409.49 KB 407.01 KB 74.25 KB 75.25 KB FB_WWW_PROD
react-dom-server.browser.development.js 0.0% -0.0% 135.46 KB 135.46 KB 36.12 KB 36.12 KB NODE_DEV
ReactDOM-profiling.js -0.8% +1.1% 421.02 KB 417.61 KB 76.17 KB 77.03 KB FB_WWW_PROFILING
react-dom-server.browser.production.min.js 0.0% -0.0% 19.8 KB 19.8 KB 7.43 KB 7.43 KB NODE_PROD
ReactDOMServer-dev.js -0.0% -0.0% 146.59 KB 146.53 KB 37.28 KB 37.26 KB FB_WWW_DEV
ReactDOMServer-prod.js 0.0% -0.0% 47.44 KB 47.44 KB 11.11 KB 11.11 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% -0.0% 75.25 KB 75.25 KB 20.1 KB 20.09 KB UMD_DEV

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-prod.js -1.1% 🔺+2.5% 250.16 KB 247.38 KB 42.67 KB 43.74 KB FB_WWW_PROD
react-art.development.js +2.1% +2.7% 650.34 KB 663.74 KB 137.45 KB 141.12 KB UMD_DEV
react-art.production.min.js 🔺+0.4% 🔺+2.2% 108.95 KB 109.4 KB 33.12 KB 33.85 KB UMD_PROD
react-art.development.js +2.2% +3.0% 553.82 KB 566.27 KB 119.73 KB 123.35 KB NODE_DEV
react-art.production.min.js 🔺+0.6% 🔺+3.4% 73.95 KB 74.42 KB 22.26 KB 23.03 KB NODE_PROD
ReactART-dev.js +0.4% +1.8% 617.6 KB 620.29 KB 129.76 KB 132.04 KB FB_WWW_DEV

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 12.73 KB 12.73 KB 3.96 KB 3.96 KB UMD_PROD
react-test-renderer.development.js +2.3% +2.9% 588.76 KB 602.27 KB 122.84 KB 126.45 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.6% 🔺+3.3% 76.13 KB 76.58 KB 23.18 KB 23.96 KB UMD_PROD
react-test-renderer.development.js +2.2% +3.0% 561.28 KB 573.83 KB 121.35 KB 124.99 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.6% 🔺+3.3% 75.92 KB 76.4 KB 22.9 KB 23.65 KB NODE_PROD
ReactTestRenderer-dev.js +1.7% +2.7% 586.91 KB 597.1 KB 124.47 KB 127.86 KB FB_WWW_DEV
ReactTestRenderer-dev.js +1.8% +2.7% 579.46 KB 590.16 KB 124.23 KB 127.58 KB RN_FB_DEV

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +1.6% +2.4% 667.66 KB 678.24 KB 143.42 KB 146.83 KB RN_OSS_DEV
ReactNativeRenderer-prod.js -0.6% 🔺+2.2% 273.49 KB 271.9 KB 47.21 KB 48.25 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js -0.7% +1.9% 285.5 KB 283.4 KB 49.49 KB 50.45 KB RN_OSS_PROFILING
ReactFabric-dev.js +1.6% +2.4% 648.89 KB 658.95 KB 138.95 KB 142.22 KB RN_OSS_DEV
ReactFabric-prod.js -0.4% 🔺+2.6% 266.6 KB 265.61 KB 45.8 KB 46.99 KB RN_OSS_PROD
ReactFabric-profiling.js -0.5% +2.3% 278.64 KB 277.15 KB 48.09 KB 49.21 KB RN_OSS_PROFILING

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +2.1% +2.9% 608.95 KB 621.8 KB 129.29 KB 133.02 KB NODE_DEV
react-reconciler-reflection.development.js 0.0% -0.0% 16.68 KB 16.68 KB 4.98 KB 4.98 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.5% 🔺+3.1% 83.37 KB 83.77 KB 24.95 KB 25.73 KB NODE_PROD
react-reconciler-reflection.production.min.js 0.0% -0.2% 2.8 KB 2.8 KB 1.15 KB 1.15 KB NODE_PROD

ReactDOM: size: 0.0%, gzip: -0.0%

Size changes (stable)

Generated by 🚫 dangerJS against ada036b

@@ -2160,7 +2160,7 @@ export function attach(
const dependencies =
(fiber: any).dependencies ||
(fiber: any).dependencies_old ||
(fiber: any).dependencies_new;
(fiber: any).dependencies;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this statement doesn't look quite right

acdlite added 4 commits June 11, 2020 19:45
For each file in the new fork, copies the contents into the
corresponding file of the old fork, replacing what was already there.

In contrast to merge-fork, which performs a three-way merge.
First I ran  `yarn replace-fork`.

Then I ran `yarn lint` with autofix enabled. There's currently no way to
do that from the command line (we should fix that), so I had to edit the
lint script file.
Removes dead branches, removes prefixes from internal fields.  Stuff
like that.
@acdlite acdlite force-pushed the replace-old-fork branch from 4fc3d3b to c7b73c2 Compare June 12, 2020 02:46
DevTools tests only run against the old fork, which is why I didn't
catch these earlier.

There is one test that is still failing. I'm fairly certain it's related
to the layout of the Suspense fiber: we no longer conditionally wrap the
primary children. They are always wrapped in an extra fiber.

Since this has been running in www for weeks without major issues, I'll
defer fixing the remaining test to a follow up.
@acdlite acdlite force-pushed the replace-old-fork branch from c7b73c2 to ada036b Compare June 12, 2020 02:48
@acdlite acdlite merged commit 8f05f2b into facebook:master Jun 12, 2020
@acdlite
Copy link
Collaborator Author

acdlite commented Jun 12, 2020

@bvaughn Some of the DevTools tests were broken. Only noticed now because DevTools tests only run against the old fork. The failures were related to the layout of the Suspense fiber, since the primary tree is now always wrapped in an extra fiber. I was able to fix most of them with a small change.

There is one remaining test failure that I couldn't figure out. It's related to the same thing, but since I'm not familiar with that part of the DevTools code, I think if I tried to change anything else I'd end up breaking it in some other way. Since it's already been running in www for weeks, I figure it's OK to land as-is and fix it forward, once you're back from PTO and can give me some pointers.

@bvaughn
Copy link
Contributor

bvaughn commented Jun 14, 2020

Ooh, we should get DevTools tests running against both reconcilers I guess. I wonder how hard that would be. Are we building the new reconciler into any artifacts (e.g. experimental?

@bvaughn
Copy link
Contributor

bvaughn commented Jun 15, 2020

Is this the error you were seeing?

Error: Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.

(This is the one I see when I uncomment those lines in store-test.js.)

I believe @gaearon wrote that particular test case (d81d74b) to cover how DevTools handles various Suspense state transitions. It looks like one of the transitions, specifically, causes this to fail.

linjiajian999 pushed a commit to linjiajian999/react that referenced this pull request Jun 16, 2020
* Add autofix to cross-fork lint rule

* replace-fork: Replaces old fork contents with new

For each file in the new fork, copies the contents into the
corresponding file of the old fork, replacing what was already there.

In contrast to merge-fork, which performs a three-way merge.

* Replace old fork contents with new fork

First I ran  `yarn replace-fork`.

Then I ran `yarn lint` with autofix enabled. There's currently no way to
do that from the command line (we should fix that), so I had to edit the
lint script file.

* Manual fix-ups

Removes dead branches, removes prefixes from internal fields.  Stuff
like that.

* Fix DevTools tests

DevTools tests only run against the old fork, which is why I didn't
catch these earlier.

There is one test that is still failing. I'm fairly certain it's related
to the layout of the Suspense fiber: we no longer conditionally wrap the
primary children. They are always wrapped in an extra fiber.

Since this has been running in www for weeks without major issues, I'll
defer fixing the remaining test to a follow up.
@bvaughn
Copy link
Contributor

bvaughn commented Jun 17, 2020

I'm still a little baffled by this error. Through a bit of bisecting, I was able to suppress the bizarre console.error call by disabling the _adjustParentTreeWeight call inside of the TREE_OPERATION_ADD case in onBridgeOperations but I'm not yet sure why this would have anything to do with anything.

The thing that makes this weird is that the error is being thrown by commitMutationEffectsImpl (more specifically by commitDeletion - when it tries to delete the test <Never> component) in ReactDOM which isn't the context that DevTools is running in. ReactDOM is what's rendering the test app code. DevTools is listening to ReactDOM and updating its Store- via the call to onBridgeOperations- which happens after the error has already been thrown.

I must be forgetting how one of these pieces connects.

Edit 1 Looks like there's an extra call to (ReactDOM) performSyncWorkOnRoot when I haven't removed the call to _adjustParentTreeWeight. That's unexpected.

Edit 2 Ah, that's because the DevTools test is calling overrideSuspense which forces ReactDOM to re-render. The reason removing _adjustParentTreeWeight "fixes" the error is that it causes the find-id-at-index lookup to fail which causes the call to overrideSuspense to be ignored. So that was a bad lead.

Edit 3 I assume the problem is that DevTools has a bad assumption about the state of the tree b'c of the change in the extra wrapper Fiber. Reverting the changes made to backend/renderer.js in this PR "fixes" the error, but I'm not yet sure why.

Edit 4 Looks like the logic for areSuspenseChildrenConditionallyWrapped is wrong in this specific test. Reverting to the old implementation "fixes" this test- but only in that calling overrideSuspense doesn't actually re-render anything (or rather, React doesn't actually call our injected shouldSuspendFiberAccordingToSet function).

@bvaughn
Copy link
Contributor

bvaughn commented Jun 18, 2020

Okay. Coming back at this today with a fresh perspective.

The test has a component called Never:

const Never = () => {
  throw new Promise(() => {});
};

I think what's happening is this:

  1. The Never component is rendered, but never completes (because it throws a Promise that never resolves).
  2. The store-test tells DevTools to force Never's parent Suspense boundary to un-suspend- so React tags it with a DidCapture effect.
  3. React later tries to commit a deletion for the Never fiber. However it was already deleted, as part of the previous render, so the return pointer is null and React throws.

Step 3 is different behavior between the old and new reconciler implementations. (The old reconciler doe not try to commit a deletion for Never after step 3.)

So why does the new one? Stepping through the code, the force suspend doesn't actually tag Never (or anything else) with a Deletion effect. It looks like this effect is actually left over from the previous commit.

The failing test case can be reduced to these three steps:

act(() =>
  ReactDOM.render(
    <Wrapper
      suspendParent={false}
      suspendFirst={true}
      suspendSecond={true}
    />,
    container
  )
);

// This update deletes the Never component rendered by the previous commit:
act(() =>
  ReactDOM.render(
    <Wrapper
      suspendParent={false}
      suspendFirst={false}
      suspendSecond={false}
    />,
    container
  )
);

// This update incorrectly tries to commit a second deletion for Never:
const rendererID = getRendererID();
act(() =>
  agent.overrideSuspense({
    id: store.getElementIDAtIndex(4),
    rendererID,
    forceFallback: true,
  })
);

Edit I think the problem is that the call to updateSuspenseFallbackChildren is putting Never back into the effect list after step 3. In the old reconciler, I think the equivalent section of code cloned the children (which reset their effects).

@bvaughn
Copy link
Contributor

bvaughn commented Jun 18, 2020

While debugging this, I also noticed that running tests with the new backend/renderer (after your changes in this PR) against an older React build fails- which concerns me. DevTools should support older versions of React. Although maybe in this case the version it fails for was never actually released and so it would not be a real problem... we need to run the test suite against 16.13.1 at some point and make sure it doesn't break for it.

@acdlite
Copy link
Collaborator Author

acdlite commented Jun 19, 2020

Although maybe in this case the version it fails for was never actually released and so it would not be a real problem... we need to run the test suite against 16.13.1 at some point and make sure it doesn't break for it.

Ooh I did remove the check for dependencies_new and dependencies_old. Can't recall if that was ever released.

acdlite added a commit to acdlite/react that referenced this pull request Jun 19, 2020
DevTools has a feature to force a Suspense boundary to show a fallback.
This feature causes us to skip the first render pass (where we render
the primary children) and go straight to rendering the fallback.

There's a Legacy Mode-only codepath that failed to take this scenario
into account, instead assuming that whenever a fallback is being
rendered, it was preceded by an attempt to render the primary children.

SuspenseList can also cause us to skip the first pass, but the revelant
branch is Legacy Mode-only, and SuspenseList is not supported in
Legacy Mode.

Fixes a test that I had temporarily disabled when upstreaming the Lanes
implementation in facebook#19108.
acdlite added a commit to acdlite/react that referenced this pull request Jun 19, 2020
DevTools has a feature to force a Suspense boundary to show a fallback.
This feature causes us to skip the first render pass (where we render
the primary children) and go straight to rendering the fallback.

There's a Legacy Mode-only codepath that failed to take this scenario
into account, instead assuming that whenever a fallback is being
rendered, it was preceded by an attempt to render the primary children.

SuspenseList can also cause us to skip the first pass, but the relevant
branch is Legacy Mode-only, and SuspenseList is not supported in
Legacy Mode.

Fixes a test that I had temporarily disabled when upstreaming the Lanes
implementation in facebook#19108.
acdlite added a commit to acdlite/react that referenced this pull request Jun 19, 2020
DevTools has a feature to force a Suspense boundary to show a fallback.
This feature causes us to skip the first render pass (where we render
the primary children) and go straight to rendering the fallback.

There's a Legacy Mode-only codepath that failed to take this scenario
into account, instead assuming that whenever a fallback is being
rendered, it was preceded by an attempt to render the primary children.

SuspenseList can also cause us to skip the first pass, but the relevant
branch is Legacy Mode-only, and SuspenseList is not supported in
Legacy Mode.

Fixes a test that I had temporarily disabled when upstreaming the Lanes
implementation in facebook#19108.
acdlite added a commit that referenced this pull request Jun 19, 2020
DevTools has a feature to force a Suspense boundary to show a fallback.
This feature causes us to skip the first render pass (where we render
the primary children) and go straight to rendering the fallback.

There's a Legacy Mode-only codepath that failed to take this scenario
into account, instead assuming that whenever a fallback is being
rendered, it was preceded by an attempt to render the primary children.

SuspenseList can also cause us to skip the first pass, but the relevant
branch is Legacy Mode-only, and SuspenseList is not supported in
Legacy Mode.

Fixes a test that I had temporarily disabled when upstreaming the Lanes
implementation in #19108.
@acdlite
Copy link
Collaborator Author

acdlite commented Jun 20, 2020

This ended up being the crux of the issue:

I think the problem is that the call to updateSuspenseFallbackChildren is putting Never back into the effect list after step 3. In the old reconciler, I think the equivalent section of code cloned the children (which reset their effects).

See #19164 for the fix. Thanks for narrowing that down!

@acdlite
Copy link
Collaborator Author

acdlite commented Jun 20, 2020

Ooh, we should get DevTools tests running against both reconcilers I guess. I wonder how hard that would be. Are we building the new reconciler into any artifacts (e.g. experimental)?

The ReactDOMForked-* www artifacts use the new reconciler.

trueadm pushed a commit to trueadm/react that referenced this pull request Jun 22, 2020
DevTools has a feature to force a Suspense boundary to show a fallback.
This feature causes us to skip the first render pass (where we render
the primary children) and go straight to rendering the fallback.

There's a Legacy Mode-only codepath that failed to take this scenario
into account, instead assuming that whenever a fallback is being
rendered, it was preceded by an attempt to render the primary children.

SuspenseList can also cause us to skip the first pass, but the relevant
branch is Legacy Mode-only, and SuspenseList is not supported in
Legacy Mode.

Fixes a test that I had temporarily disabled when upstreaming the Lanes
implementation in facebook#19108.
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.

6 participants