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

Make enableOwnerStacks dynamic #31661

Merged
merged 13 commits into from
Dec 11, 2024
Merged

Make enableOwnerStacks dynamic #31661

merged 13 commits into from
Dec 11, 2024

Conversation

noahlemen
Copy link
Member

following up on #31287, fixing tests

Copy link

vercel bot commented Dec 3, 2024

Deployment failed with the following error:

You don't have permission to create a Preview Deployment for this project.

View Documentation: https://vercel.com/docs/accounts/team-members-and-roles

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Dec 3, 2024
@react-sizebot
Copy link

react-sizebot commented Dec 3, 2024

Comparing: 79ddf5b...e06f8b8

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 510.76 kB 510.76 kB = 91.41 kB 91.41 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 515.69 kB 515.69 kB = 92.12 kB 92.12 kB
facebook-www/ReactDOM-prod.classic.js = 595.61 kB 595.61 kB = 105.12 kB 105.12 kB
facebook-www/ReactDOM-prod.modern.js = 585.88 kB 585.88 kB = 103.55 kB 103.55 kB
facebook-react-native/react/cjs/JSXRuntime-dev.js +7.30% 24.61 kB 26.40 kB +4.69% 5.95 kB 6.23 kB
facebook-react-native/react/cjs/JSXDEVRuntime-dev.js +6.53% 24.54 kB 26.14 kB +4.53% 5.94 kB 6.21 kB
facebook-www/JSXDEVRuntime-dev.classic.js +5.86% 26.64 kB 28.20 kB +3.83% 6.38 kB 6.62 kB
facebook-www/JSXDEVRuntime-dev.modern.js +5.86% 26.64 kB 28.20 kB +3.83% 6.38 kB 6.62 kB
facebook-react-native/react/cjs/React-dev.js +4.56% 63.49 kB 66.38 kB +2.71% 14.22 kB 14.60 kB
facebook-www/React-dev.modern.js +4.22% 68.20 kB 71.08 kB +2.49% 15.07 kB 15.45 kB
facebook-www/React-dev.classic.js +4.22% 68.20 kB 71.08 kB +2.49% 15.07 kB 15.45 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-react-native/react/cjs/JSXRuntime-dev.js +7.30% 24.61 kB 26.40 kB +4.69% 5.95 kB 6.23 kB
facebook-react-native/react/cjs/JSXDEVRuntime-dev.js +6.53% 24.54 kB 26.14 kB +4.53% 5.94 kB 6.21 kB
facebook-www/JSXDEVRuntime-dev.classic.js +5.86% 26.64 kB 28.20 kB +3.83% 6.38 kB 6.62 kB
facebook-www/JSXDEVRuntime-dev.modern.js +5.86% 26.64 kB 28.20 kB +3.83% 6.38 kB 6.62 kB
facebook-react-native/react/cjs/React-dev.js +4.56% 63.49 kB 66.38 kB +2.71% 14.22 kB 14.60 kB
facebook-www/React-dev.modern.js +4.22% 68.20 kB 71.08 kB +2.49% 15.07 kB 15.45 kB
facebook-www/React-dev.classic.js +4.22% 68.20 kB 71.08 kB +2.49% 15.07 kB 15.45 kB
facebook-www/ReactDOMServer-dev.modern.js +1.71% 356.21 kB 362.30 kB +1.39% 64.74 kB 65.64 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js +1.70% 348.12 kB 354.05 kB +1.29% 63.51 kB 64.33 kB
facebook-www/ReactDOMServer-dev.classic.js +1.61% 363.34 kB 369.17 kB +1.24% 65.79 kB 66.60 kB
react-native/implementations/ReactFabric-dev.fb.js +0.82% 667.36 kB 672.80 kB +0.73% 108.72 kB 109.52 kB
react-native/implementations/ReactNativeRenderer-dev.fb.js +0.81% 674.51 kB 679.95 kB +0.72% 110.14 kB 110.93 kB
facebook-www/ReactART-dev.modern.js +0.72% 645.98 kB 650.64 kB +0.78% 102.70 kB 103.50 kB
facebook-www/ReactART-dev.classic.js +0.71% 655.86 kB 660.52 kB +0.74% 104.69 kB 105.47 kB
facebook-www/ReactReconciler-dev.modern.js +0.66% 731.46 kB 736.28 kB +0.72% 115.54 kB 116.38 kB
facebook-www/ReactReconciler-dev.classic.js +0.65% 740.97 kB 745.80 kB +0.66% 117.40 kB 118.17 kB
facebook-react-native/react-dom/cjs/ReactDOMClient-dev.js +0.58% 985.17 kB 990.93 kB +0.61% 165.94 kB 166.95 kB
facebook-react-native/react-dom/cjs/ReactDOMProfiling-dev.js +0.57% 1,001.51 kB 1,007.27 kB +0.60% 168.76 kB 169.76 kB
facebook-www/ReactDOM-dev.modern.js +0.54% 1,065.38 kB 1,071.14 kB +0.58% 177.93 kB 178.96 kB
facebook-www/ReactDOM-dev.classic.js +0.54% 1,074.83 kB 1,080.59 kB +0.57% 179.74 kB 180.76 kB
facebook-www/ReactDOMTesting-dev.modern.js +0.53% 1,082.29 kB 1,088.04 kB +0.56% 181.88 kB 182.89 kB
facebook-www/ReactDOMTesting-dev.classic.js +0.53% 1,091.74 kB 1,097.49 kB +0.56% 183.66 kB 184.69 kB

Generated by 🚫 dangerJS against d82a7b4

@noahlemen noahlemen force-pushed the rh/dymanic-owner-stacks branch from 43b4f2b to 25b3193 Compare December 3, 2024 16:25
flags.enableOwnerStacks
? [
'Component uses the legacy childContextTypes API which will soon be removed. Use React.createContext() instead.',
{withoutStack: true},
Copy link
Member Author

Choose a reason for hiding this comment

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

this doesn't seem like it should be needed, still working on figuring out what's going on here

Copy link
Member Author

Choose a reason for hiding this comment

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

think this may actually be correct. the error below for contextTypes has an owner stack because it is on Foo, which is rendered by Outer. childContextTypes is on Outer, however, which has no owner – it is rendered directly by root.render. If Outer is wrapped with an arbitrary wrapper component, we get a stack here.

Copy link
Member

Choose a reason for hiding this comment

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

why wasn't this failing before though?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a bug in the checker to me. Why do we need to gate only first message?

Copy link
Member Author

Choose a reason for hiding this comment

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

@hoxyq see my second comment - it seems there's no "owner" to point to (it would be the root.render call on L338), so there's no stack

@rickhanlonii it wasn't failing before because owner stacks weren't enabled until this PR, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

see my second comment - it seems there's no "owner" to point to (it would be the root.render call on L338), so there's no stack

Makes sense, but when enableOwnerStacks is disabled, classic component stacks should be appended, which will be empty in this case as well, but was working well without specifying withoutStack property.

Copy link
Member Author

@noahlemen noahlemen Dec 4, 2024

Choose a reason for hiding this comment

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

that's true - it appears that with enableOwnerStacks disabled the component stack here ends up pointing at that anonymous function. not sure if we should expect owner stacks to do the same?

Copy link
Contributor

Choose a reason for hiding this comment

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

that's true - it appears that with enableOwnerStacks disabled the component stack here ends up pointing at that anonymous function. not sure if we should expect owner stacks to do the same?

oh, now I get it, so non-empty component stack gets appended, if feature flag is disabled, but once its enabled, then the owner stack is empty and its basically a false-positive

thanks for the explanation

Copy link
Member Author

Choose a reason for hiding this comment

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

why wasn't this failing before though?

to fully close the loop on this, @rickhanlonii, it seems its just because with enableOwnerStacks prior only enabled in experimental, disableLegacyContext was always enabled

since this test has // @gate !disableLegacyContext, it plainly was never running before when enableOwnerStacks was gated, as there wasn't a permutation of the feature flags where disableLegacyContext was false but enableOwnerStacks was true. enableOwnerStacks was only ever true when disableLegacyContext was already true.

@noahlemen noahlemen marked this pull request as ready for review December 3, 2024 21:37
Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

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

Need to double check the ReactServer export, but otherwise good

let captureOwnerStack: ?() => null | string;
if (enableOwnerStacks) {
captureOwnerStack = captureOwnerStackImpl;
}
Copy link
Member

Choose a reason for hiding this comment

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

This is sus, why does this need exported here but not from the other ReactServer.js exports?

Copy link
Member Author

Choose a reason for hiding this comment

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

in your PR it was added without the flag check, which seemed to break feature detection in the tests. so i added the gating, which corrected it.

you're right though, i hadn't noticed that ReactServer.js doesn't export it at all. looks like just not changing this file at all would be a valid approach too.

Copy link
Member Author

@noahlemen noahlemen Dec 11, 2024

Choose a reason for hiding this comment

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

after investigating this a bit more, i think exporting this dynamically based on the feature flag is correct.

in the experimental builds we have a dedicated file for the development builds (ReactServer.experimental.development vs ReactServer.experimental, index.experimental.development vs index.experimental) and only export captureOwnerStack in the development version.

the *.fb files do not have separate development versions, so if we want parity with experimental, we should gate defining the export on __DEV__.

however, if we gate based on just that, we still get some failures. there's another subtle inconsistency - in experimental builds the flag is always enabled. here, we use __VARIANT__, which creates a situation where, if we gate only based on __DEV__ we could export a defined captureOwnerStack but have enableOwnerStacks disabled (eg: when tests are run with --variant=false).

because some of the existing test infrastructure code (1, 2) for handling this operates based on feature detection of captureOwnerStack being defined, this is very consequential for how the tests are ultimately run.

flags.enableOwnerStacks
? [
'Component uses the legacy childContextTypes API which will soon be removed. Use React.createContext() instead.',
{withoutStack: true},
Copy link
Member

Choose a reason for hiding this comment

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

why wasn't this failing before though?

@noahlemen noahlemen merged commit a496498 into main Dec 11, 2024
182 of 183 checks passed
@noahlemen noahlemen deleted the rh/dymanic-owner-stacks branch December 11, 2024 17:00
github-actions bot pushed a commit that referenced this pull request Dec 11, 2024
following up on #31287, fixing
tests

---------

Co-authored-by: Rick Hanlon <rickhanlonii@fb.com>

DiffTrain build for [a496498](a496498)
github-actions bot pushed a commit that referenced this pull request Dec 11, 2024
following up on #31287, fixing
tests

---------

Co-authored-by: Rick Hanlon <rickhanlonii@fb.com>

DiffTrain build for [a496498](a496498)
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.

5 participants