Skip to content

Conversation

lunaruan
Copy link
Contributor

Previously, the suspense priority warning was fired even if the Root wasn't suspended. Changed the warning to fire only when the root is suspended.

Also refactored the suspense priority warning so it's easier to read.

@@ -1738,6 +1710,38 @@ describe('ReactSuspenseWithNoopRenderer', () => {
);
});

it('', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing test name

);
expect(console.error.calls.argsFor(0)[1]).toContain(
'A user-blocking update was suspended by:',
'Warning: A user-blocking update was suspended by:',
);
expect(console.error.calls.argsFor(0)[1]).toContain('AsyncText');
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this code already existed but curious — any reason we’re not using toWarnDev() for this warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it was easier at the time to use console.error, because there was a lot of them. Do you prefer toWarnDev()?

@sizebot
Copy link

sizebot commented Jul 30, 2019

ReactDOM: size: 0.0%, gzip: 0.0%

Details of bundled changes.

Comparing: db3ae32...c22465d

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js -0.2% -0.1% 644.5 KB 643.38 KB 140.61 KB 140.43 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 102.54 KB 102.54 KB 31.26 KB 31.26 KB UMD_PROD
react-art.development.js -0.2% -0.2% 575.38 KB 574.26 KB 123.32 KB 123.13 KB NODE_DEV
react-art.production.min.js 0.0% 0.0% 67.59 KB 67.59 KB 20.62 KB 20.62 KB NODE_PROD
ReactART-dev.js -0.2% -0.2% 589.27 KB 588.04 KB 122.87 KB 122.68 KB FB_WWW_DEV
ReactART-prod.js 0.0% 0.0% 220.64 KB 220.64 KB 37.65 KB 37.65 KB FB_WWW_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js 0.0% 0.0% 115.28 KB 115.28 KB 36.27 KB 36.27 KB NODE_PROFILING
react-dom-server.browser.development.js 0.0% 0.0% 136.93 KB 136.93 KB 36.2 KB 36.2 KB UMD_DEV
ReactDOM-dev.js -0.1% -0.1% 932.29 KB 931.06 KB 206.25 KB 206.04 KB FB_WWW_DEV
react-dom-server.browser.production.min.js 0.0% 0.0% 19.35 KB 19.35 KB 7.24 KB 7.24 KB UMD_PROD
react-dom-test-utils.development.js 0.0% 0.0% 55.72 KB 55.72 KB 14.94 KB 14.95 KB UMD_DEV
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.78 KB 3.78 KB 1.52 KB 1.52 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 11.19 KB 11.19 KB 4.11 KB 4.11 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.3% 1.21 KB 1.21 KB 705 B 707 B UMD_PROD
react-dom-test-utils.development.js 0.0% 0.0% 53.99 KB 53.99 KB 14.62 KB 14.62 KB NODE_DEV
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.61 KB 3.61 KB 1.47 KB 1.48 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 10.97 KB 10.97 KB 4.04 KB 4.04 KB NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.3% 1.05 KB 1.05 KB 636 B 638 B NODE_PROD
react-dom.development.js -0.1% -0.1% 908.86 KB 907.74 KB 205.94 KB 205.76 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 111.56 KB 111.56 KB 35.81 KB 35.81 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 115.01 KB 115.01 KB 36.88 KB 36.88 KB UMD_PROFILING
react-dom.development.js -0.1% -0.1% 903.16 KB 902.04 KB 204.46 KB 204.27 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 111.62 KB 111.62 KB 35.32 KB 35.32 KB NODE_PROD
react-dom-server.node.production.min.js 0.0% 0.0% 20.13 KB 20.13 KB 7.55 KB 7.55 KB NODE_PROD
ReactDOM-prod.js 0.0% 0.0% 372.87 KB 372.87 KB 68.53 KB 68.53 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% 0.0% 377.77 KB 377.77 KB 69.62 KB 69.62 KB FB_WWW_PROFILING
react-dom-server.browser.production.min.js 0.0% 0.0% 19.28 KB 19.28 KB 7.25 KB 7.25 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.76 KB 60.76 KB 15.85 KB 15.85 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 🔺+0.1% 10.74 KB 10.74 KB 3.68 KB 3.68 KB UMD_PROD
ReactDOMServer-dev.js 0.0% 0.0% 135.09 KB 135.09 KB 34.65 KB 34.66 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.43 KB 60.43 KB 15.72 KB 15.72 KB NODE_DEV
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 3.85 KB 3.85 KB 1.5 KB 1.5 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 🔺+0.1% 10.48 KB 10.48 KB 3.58 KB 3.58 KB NODE_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.5% 1.1 KB 1.1 KB 666 B 669 B NODE_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js -0.2% -0.2% 600.26 KB 599.03 KB 125.32 KB 125.12 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% 0.0% 39.37 KB 39.37 KB 9.92 KB 9.92 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% 🔺+0.1% 11.62 KB 11.62 KB 3.55 KB 3.55 KB UMD_PROD
react-test-renderer-shallow.development.js 0.0% 0.0% 33.5 KB 33.5 KB 8.51 KB 8.51 KB NODE_DEV
react-test-renderer-shallow.production.min.js 0.0% 🔺+0.1% 11.77 KB 11.77 KB 3.67 KB 3.67 KB NODE_PROD
react-test-renderer.development.js -0.2% -0.1% 588.3 KB 587.18 KB 125.9 KB 125.73 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 69.14 KB 69.14 KB 21.14 KB 21.14 KB UMD_PROD
react-test-renderer.development.js -0.2% -0.1% 583.84 KB 582.72 KB 124.79 KB 124.61 KB NODE_DEV
react-test-renderer.production.min.js 0.0% 0.0% 68.89 KB 68.89 KB 20.93 KB 20.93 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js -0.2% -0.1% 573.46 KB 572.35 KB 121.89 KB 121.71 KB NODE_DEV
react-reconciler.production.min.js 0.0% 0.0% 68.79 KB 68.79 KB 20.45 KB 20.45 KB NODE_PROD
react-reconciler-reflection.development.js 0.0% 0.0% 16.63 KB 16.63 KB 5.16 KB 5.16 KB NODE_DEV
react-reconciler-reflection.production.min.js 0.0% 🔺+0.3% 2.59 KB 2.59 KB 1.14 KB 1.14 KB NODE_PROD
react-reconciler-persistent.development.js -0.2% -0.2% 570.48 KB 569.36 KB 120.62 KB 120.44 KB NODE_DEV
react-reconciler-persistent.production.min.js 0.0% 0.0% 68.8 KB 68.8 KB 20.45 KB 20.46 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-prod.js 0.0% 0.0% 272.15 KB 272.15 KB 46.74 KB 46.74 KB RN_OSS_PROD
ReactFabric-prod.js 0.0% 0.0% 265.82 KB 265.82 KB 45.78 KB 45.78 KB RN_OSS_PROD
ReactFabric-dev.js -0.2% -0.1% 736 KB 734.77 KB 155.59 KB 155.39 KB RN_FB_DEV
ReactNativeRenderer-dev.js -0.2% -0.1% 723.29 KB 722.06 KB 153.13 KB 152.94 KB RN_OSS_DEV
ReactFabric-profiling.js 0.0% 0.0% 274.69 KB 274.69 KB 47.29 KB 47.29 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js -0.2% -0.1% 723.38 KB 722.16 KB 153.18 KB 152.98 KB RN_FB_DEV
ReactNativeRenderer-prod.js 0.0% 0.0% 272.14 KB 272.14 KB 46.75 KB 46.75 KB RN_FB_PROD
ReactNativeRenderer-profiling.js 0.0% 0.0% 280.72 KB 280.72 KB 48.32 KB 48.32 KB RN_FB_PROFILING
ReactFabric-dev.js -0.2% -0.1% 735.9 KB 734.67 KB 155.55 KB 155.35 KB RN_OSS_DEV

Generated by 🚫 dangerJS

@lunaruan lunaruan changed the title Fix suspense priority warning firing when not supposed to BugFix suspense priority warning firing when not supposed to Jul 30, 2019
@lunaruan lunaruan changed the title BugFix suspense priority warning firing when not supposed to BugFix: Suspense priority warning firing when not supposed to Jul 30, 2019
Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

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

This still adds all the suspended components to the component names lists. That seems misleading at best. Because if some other boundary during the same commit ended up suspending, then we'd show all the suspended components rather than just the new one.

It seems to me that we should only add the component names/promises that contributed to suspending.

I.e. we should move the logic from throwException into here: https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js#L882-L896

@acdlite
Copy link
Collaborator

acdlite commented Jul 30, 2019

@sebmarkbage Luna and I discussed this before she submitted the PR. The issue is that if we wait until the complete phase, we've lost track of the components that suspended in that subtree. So we'll need to track them via some mechanism, like on the stack.

Or we could omit the names of the components that suspended from the message. I think the names of the components that triggered the update are the more relevant piece of information. Though arguably, the names of the components that suspended could also be helpful for debugging in the useSuspenseDeferredValue case.

@acdlite
Copy link
Collaborator

acdlite commented Jul 30, 2019

I was kind of hoping we could omit the names of the components that suspended, given that the implementation is annoying, and rely React DevTools to surface this information instead, eventually.

@sebmarkbage
Copy link
Collaborator

I think what you really want is what suspended. As in what is the Promise associated with. That's why we're now attaching debug info to the promises. Not the nearest component that threw one. With call through and other optimizations we might not know the exact component. We should only need try/catch at boundary levels, not nearest component. This is unfortunate leak.

So I'd be in favor removing that from the message.

@acdlite
Copy link
Collaborator

acdlite commented Jul 31, 2019

Ok @lunaruan in that case you can leave the checkForWrongSuspensePriorityInDEV call where it is, and only flush the warning in the RootSuspended or RootSuspendedWithDelay cases, as you've already done. Then remove the names of the components that threw from the message.

Should also add a test where the component that triggers the update is in between the Suspense boundary and the component that throws.

@lunaruan lunaruan merged commit c4c9f08 into facebook:master Aug 2, 2019
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.

6 participants