-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
Debug render-phase side effects in "strict" mode #12094
Conversation
This determines whether StrictMode double-invokes render phase lifecycles or not. By default, it is enabled for NODE_ENV "development".
This change breaks the following tests:
Two of them are internal and so will be easy to fix. The rest of them are incremental tests, built with the (private) noop-renderer, and so should be okay to make internal-only. The only exception is |
That seems a bit unfortunate to me. They describe the async behavior in detail and I intentionally worked to get the noop renderer to build in a way that this behavior is testable. We're undoing this work here, and I'm not sure for how long (can we remove this later?) Technically this used to verifiy that our custom renderer infrastructure (which I changed noop renderer bundle to use) is working. Making those tests internal defies that somewhat. I understand it's important to unblock this but I hope we can go back to running them on the bundles before we break something else and it becomes a lot of work again. |
Hm. Interesting perspective, Dan. It seems odd to me that we had tests (arguably some of our most complex tests) running against a production bundle of something that we never actually ship anywhere. And since this twice-invoking behavior adds significant complexity it felt like the right trade-off.
Maybe we can achieve the same goal with tests that aren't so complex?
I don't think this will be removed as long as the class component API is around in the form it is today. |
Testing the noop renderer seems fine for testing the custom renderer infrastructure, but I think the async tests specifically is not the right way of doing that since they have all these special quirks that you wouldn't test for in user tests or maybe even experience. It was just accidental that we ended up only having async tests for this particular renderer. |
Right, because noop renderer is always async:
So any tests for it would have to account for the double lifecycles in DEV. Granted, some of them are pretty straight forward though. |
I think the confusing part here is that testing custom renderer infra and testing async are two unrelated activities but they happen to be combined here. I think both are valuable to do against the bundles:
|
Agreed. |
Resolves #12089
A new feature flag has been added,
debugRenderPhaseSideEffectsForStrictMode
. When enabled,StrictMode
subtrees will also double-invoke lifecycles in the same way asdebugRenderPhaseSideEffects
.By default, this flag is enabled for
__DEV__
only. Internally we can toggle it with a GK.This breaks several of our incremental tests which make use of the noop-renderer. Updating the tests to account for the double-rendering in development mode makes them significantly more complicated. The most straight forward fix for this will be to convert them to be run as internal tests only. I believe this is reasonable since we are the only people making use of the noop renderer.