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

warn if passive effects get queued outside of an act() call. #15631

Conversation

threepointone
Copy link
Contributor

@threepointone threepointone commented May 12, 2019

This version uses a feature flag to disable the warning in tests. It isn't a viable options since we'd have to disable a whole lot of tests that run in yarn test-build See #15763 instead


based on #15591. this might be a bit controversial, but I agree with the reasoning. of note, we don't modify our own tests to satisfy this warning, instead using a feature flag to disable the warning for some tests. this is because we're testing the actual sequencing of work in these tests, and don't want to flush everything with act().

you probably want to see just this commit - 9f7a346

Sunil Pai added 11 commits May 8, 2019 18:05
a first crack at flushing the scheduler manually from inside act(). uses unstable_flushWithoutYielding(). The tests that changes, mostly replaced toFlushAndYield(...) with toHaveYielded(). For some tests that tested the state of the tree before flushing effects (but still after updates), I replaced act() with bacthedUpdates().
of note, unstable_flushWithoutYielding now returns a boolean much like flushPassiveEffects
I also tried writing a test for it, but couldn't get the scheduler to unmock. included the failing test.
based on facebook#15591. of note, we don't modify our own tests to satisfy this warning, instead using a feature flag to disable the warning for some tests. this is because we're testing the actual sequencing of work in these tests, and don't want to flush everything with act().
@acdlite acdlite mentioned this pull request May 12, 2019
9 tasks
@sizebot
Copy link

sizebot commented May 12, 2019

React: size: 0.0%, gzip: -0.0%

Details of bundled changes.

Comparing: c7398f3...9f7a346

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js +0.4% +0.6% 107.92 KB 108.33 KB 27.39 KB 27.54 KB UMD_DEV
react.production.min.js 0.0% -0.0% 12.33 KB 12.33 KB 4.8 KB 4.8 KB UMD_PROD
react.profiling.min.js 0.0% -0.0% 14.48 KB 14.48 KB 5.32 KB 5.32 KB UMD_PROFILING
react.development.js +0.6% +0.9% 70.09 KB 70.5 KB 18.04 KB 18.21 KB NODE_DEV
react.production.min.js 0.0% -0.0% 6.48 KB 6.48 KB 2.69 KB 2.69 KB NODE_PROD
React-dev.js 0.0% -0.0% 68.36 KB 68.36 KB 17.38 KB 17.38 KB FB_WWW_DEV
React-prod.js 0.0% -0.0% 16.32 KB 16.32 KB 4.31 KB 4.31 KB FB_WWW_PROD
React-profiling.js 0.0% -0.0% 16.32 KB 16.32 KB 4.31 KB 4.31 KB FB_WWW_PROFILING

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js +0.2% +0.2% 825.72 KB 827.61 KB 188.5 KB 188.79 KB UMD_DEV
react-dom.profiling.min.js 0.0% -0.0% 107.15 KB 107.15 KB 34.8 KB 34.8 KB UMD_PROFILING
react-dom.development.js +0.2% +0.1% 820.13 KB 821.93 KB 186.95 KB 187.22 KB NODE_DEV
react-dom.production.min.js 0.0% -0.0% 103.98 KB 103.98 KB 33.25 KB 33.25 KB NODE_PROD
react-dom.profiling.min.js 0.0% -0.0% 107.33 KB 107.33 KB 34.14 KB 34.14 KB NODE_PROFILING
ReactDOM-dev.js +0.2% +0.1% 844.85 KB 846.4 KB 188.48 KB 188.61 KB FB_WWW_DEV
ReactDOM-profiling.js 0.0% 0.0% 351.45 KB 351.45 KB 65.08 KB 65.08 KB FB_WWW_PROFILING
react-dom-unstable-fire.development.js +0.2% +0.2% 826.05 KB 827.93 KB 188.65 KB 188.93 KB UMD_DEV
react-dom-unstable-fire.production.min.js 0.0% -0.0% 104.01 KB 104.01 KB 33.82 KB 33.82 KB UMD_PROD
react-dom-unstable-fire.profiling.min.js 0.0% -0.0% 107.16 KB 107.16 KB 34.81 KB 34.81 KB UMD_PROFILING
react-dom-unstable-fire.development.js +0.2% +0.1% 820.45 KB 822.25 KB 187.09 KB 187.36 KB NODE_DEV
react-dom-unstable-fire.production.min.js 0.0% -0.0% 104 KB 104 KB 33.26 KB 33.26 KB NODE_PROD
react-dom-unstable-fire.profiling.min.js 0.0% -0.0% 107.34 KB 107.34 KB 34.15 KB 34.15 KB NODE_PROFILING
ReactFire-dev.js +0.2% +0.1% 844.04 KB 845.59 KB 188.47 KB 188.61 KB FB_WWW_DEV
ReactFire-prod.js 0.0% 0.0% 334.22 KB 334.22 KB 61.68 KB 61.68 KB FB_WWW_PROD
ReactFire-profiling.js 0.0% 0.0% 339.41 KB 339.41 KB 62.63 KB 62.63 KB FB_WWW_PROFILING
react-dom-test-utils.development.js +4.8% +4.6% 54.23 KB 56.82 KB 14.98 KB 15.67 KB UMD_DEV
react-dom-test-utils.production.min.js 🔺+1.1% 🔺+0.8% 10.56 KB 10.67 KB 3.9 KB 3.93 KB UMD_PROD
react-dom-test-utils.development.js +2.2% +2.9% 53.95 KB 55.16 KB 14.91 KB 15.35 KB NODE_DEV
react-dom-test-utils.production.min.js 🔺+0.7% 🔺+0.9% 10.35 KB 10.43 KB 3.82 KB 3.85 KB NODE_PROD
ReactTestUtils-dev.js +1.8% +2.0% 51.44 KB 52.34 KB 13.83 KB 14.11 KB FB_WWW_DEV
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.development.js 0.0% -0.0% 60.43 KB 60.43 KB 15.72 KB 15.72 KB NODE_DEV
react-dom-server.browser.development.js +0.3% +0.5% 136.73 KB 137.14 KB 35.99 KB 36.17 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.14 KB 19.14 KB 7.22 KB 7.22 KB UMD_PROD
react-dom-server.browser.development.js +0.3% +0.5% 132.86 KB 133.27 KB 35.05 KB 35.22 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.07 KB 19.07 KB 7.21 KB 7.21 KB NODE_PROD
ReactDOMServer-dev.js 0.0% -0.0% 135.21 KB 135.21 KB 34.71 KB 34.71 KB FB_WWW_DEV
react-dom-server.node.development.js +0.3% +0.5% 134.81 KB 135.22 KB 35.6 KB 35.77 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% -0.0% 19.93 KB 19.93 KB 7.51 KB 7.51 KB NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.66 KB 3.66 KB 1.45 KB 1.45 KB UMD_DEV
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.49 KB 3.49 KB 1.41 KB 1.41 KB NODE_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.2% 1.05 KB 1.05 KB 638 B 637 B NODE_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% -0.1% 1.1 KB 1.1 KB 668 B 667 B NODE_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.3% +0.3% 564.3 KB 566.19 KB 123.66 KB 123.97 KB UMD_DEV
react-art.production.min.js 0.0% -0.0% 95.8 KB 95.8 KB 29.41 KB 29.41 KB UMD_PROD
react-art.development.js +0.4% +0.3% 495.26 KB 497.06 KB 106.24 KB 106.52 KB NODE_DEV
react-art.production.min.js 0.0% -0.0% 60.77 KB 60.77 KB 18.73 KB 18.73 KB NODE_PROD
ReactART-dev.js +0.3% +0.1% 504.77 KB 506.33 KB 105.38 KB 105.51 KB FB_WWW_DEV
ReactART-prod.js 0.0% -0.0% 196.74 KB 196.74 KB 33.43 KB 33.43 KB FB_WWW_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +0.2% +0.1% 636.83 KB 638.39 KB 135.64 KB 135.78 KB RN_FB_DEV
ReactNativeRenderer-prod.js 0.0% -0.0% 245.19 KB 245.19 KB 42.55 KB 42.55 KB RN_FB_PROD
ReactNativeRenderer-profiling.js 0.0% -0.0% 253.14 KB 253.14 KB 44.17 KB 44.17 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js +0.2% +0.1% 636.75 KB 638.31 KB 135.61 KB 135.74 KB RN_OSS_DEV
ReactNativeRenderer-prod.js 0.0% -0.0% 245.2 KB 245.2 KB 42.55 KB 42.55 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js 0.0% -0.0% 253.16 KB 253.16 KB 44.17 KB 44.17 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.2% +0.1% 625.59 KB 627.15 KB 132.88 KB 133.02 KB RN_FB_DEV
ReactFabric-prod.js 0.0% -0.0% 238.35 KB 238.35 KB 41.22 KB 41.22 KB RN_FB_PROD
ReactFabric-profiling.js 0.0% -0.0% 246.3 KB 246.3 KB 42.91 KB 42.91 KB RN_FB_PROFILING
ReactFabric-dev.js +0.2% +0.1% 625.49 KB 627.05 KB 132.85 KB 132.98 KB RN_OSS_DEV
ReactFabric-prod.js 0.0% -0.0% 238.36 KB 238.36 KB 41.22 KB 41.22 KB RN_OSS_PROD
ReactFabric-profiling.js 0.0% -0.0% 246.31 KB 246.31 KB 42.91 KB 42.91 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 +0.4% +0.3% 508.77 KB 510.93 KB 108.96 KB 109.32 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.1% 61.99 KB 62.04 KB 19.05 KB 19.07 KB UMD_PROD
react-test-renderer.development.js +0.4% +0.3% 504.31 KB 506.47 KB 107.86 KB 108.22 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.1% 61.68 KB 61.73 KB 18.9 KB 18.93 KB NODE_PROD
ReactTestRenderer-dev.js +0.5% +0.4% 515.46 KB 517.89 KB 107.64 KB 108.04 KB FB_WWW_DEV
react-test-renderer-shallow.development.js +1.0% +1.7% 41.49 KB 41.9 KB 10.64 KB 10.82 KB UMD_DEV
react-test-renderer-shallow.development.js +1.1% +1.9% 35.72 KB 36.13 KB 9.3 KB 9.48 KB NODE_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 11.73 KB 11.73 KB 3.66 KB 3.66 KB NODE_PROD

react-noop-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-noop-renderer.development.js +3.8% +5.8% 35.15 KB 36.47 KB 8.71 KB 9.22 KB NODE_DEV
react-noop-renderer.production.min.js 🔺+0.5% 🔺+0.3% 10.49 KB 10.54 KB 3.45 KB 3.46 KB NODE_PROD
react-noop-renderer-persistent.development.js +3.8% +5.8% 35.26 KB 36.59 KB 8.73 KB 9.23 KB NODE_DEV
react-noop-renderer-persistent.production.min.js 🔺+0.5% 🔺+0.3% 10.51 KB 10.56 KB 3.46 KB 3.47 KB NODE_PROD
react-noop-renderer-server.development.js 0.0% -0.1% 1.83 KB 1.83 KB 877 B 876 B NODE_DEV
react-noop-renderer-server.production.min.js 0.0% -0.2% 813 B 813 B 491 B 490 B NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.4% +0.2% 492.79 KB 494.59 KB 104.68 KB 104.94 KB NODE_DEV
react-reconciler.production.min.js 0.0% -0.0% 61.71 KB 61.71 KB 18.48 KB 18.48 KB NODE_PROD
react-reconciler-persistent.development.js +0.3% +0.1% 490.7 KB 492.09 KB 103.81 KB 103.89 KB NODE_DEV
react-reconciler-persistent.production.min.js 0.0% -0.0% 61.72 KB 61.72 KB 18.49 KB 18.49 KB NODE_PROD
react-reconciler-reflection.development.js +2.2% +3.0% 18.79 KB 19.2 KB 5.92 KB 6.1 KB NODE_DEV

scheduler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
scheduler.development.js 0.0% -0.0% 23.32 KB 23.32 KB 5.98 KB 5.98 KB NODE_DEV
scheduler.production.min.js 0.0% -0.1% 5.03 KB 5.03 KB 1.92 KB 1.92 KB NODE_PROD
scheduler-unstable_mock.development.js n/a n/a 0 B 17.66 KB 0 B 4.08 KB UMD_DEV
scheduler-unstable_mock.production.min.js n/a n/a 0 B 4.12 KB 0 B 1.7 KB UMD_PROD
scheduler-unstable_mock.development.js +0.5% +0.3% 17.39 KB 17.47 KB 4.01 KB 4.02 KB NODE_DEV
scheduler-unstable_mock.production.min.js 🔺+0.7% 🔺+0.7% 4.06 KB 4.09 KB 1.6 KB 1.61 KB NODE_PROD
SchedulerMock-dev.js +0.4% +0.3% 17.61 KB 17.69 KB 4.05 KB 4.06 KB FB_WWW_DEV
SchedulerMock-prod.js 🔺+0.5% 🔺+0.6% 11.91 KB 11.97 KB 2.45 KB 2.46 KB FB_WWW_PROD
scheduler-tracing.development.js +3.8% +7.1% 10.79 KB 11.2 KB 2.62 KB 2.81 KB NODE_DEV
scheduler-tracing.production.min.js 0.0% 🔺+0.8% 728 B 728 B 383 B 386 B NODE_PROD
scheduler-tracing.profiling.min.js 0.0% -0.1% 3.26 KB 3.26 KB 1000 B 999 B NODE_PROFILING

Generated by 🚫 dangerJS

if (ReactShouldWarnActingUpdates.current === false) {
warningWithoutStack(
false,
'An effect from %s inside a test was not wrapped in act(...).\n\n' +
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: This makes it sound like useEffect is supposed to be wrapped in act.

@acdlite
Copy link
Collaborator

acdlite commented May 15, 2019

^ approved once base PR is merged

@threepointone
Copy link
Contributor Author

I'm rewriting this to (hopefully) not need the feature flag. it'll mean rewriting a lot of the tests.

@threepointone threepointone marked this pull request as ready for review May 21, 2019 09:42
@acdlite
Copy link
Collaborator

acdlite commented May 21, 2019

@threepointone Let's land the change before updating a bunch of tests? I would prefer not to couple those.

@threepointone
Copy link
Contributor Author

made an attempt at doing this without the feature flag here - #15763

@threepointone
Copy link
Contributor Author

abandoning this for #15763

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.

None yet

4 participants