GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Move modern strict to experimental by rickhanlonii · Pull Request #28152 · react/react

Conversation

@rickhanlonii

@rickhanlonii rickhanlonii commented Jan 29, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Turn this on

Edited: ope, nvm

Details Looks like there's still an outstanding issue with this. The original PR turned off a strict effects test, which causes a stray `componentWillUnmount` to fire.

5d1ce65#diff-19df471970763c4790c2cc0811fd2726cc6a891b0e1d5dedbf6d0599240c127aR70

Before:

expect(log).toEqual([
      'constructor',
      'constructor',
      'getDerivedStateFromProps',
      'getDerivedStateFromProps',
      'render',
      'render',
      'componentDidMount',
    ]);

After:

expect(log).toEqual([
      'constructor',
      'constructor',
      'getDerivedStateFromProps',
      'getDerivedStateFromProps',
      'render',
      'render',
      'componentDidMount',
      'componentWillUnmount',
      'componentDidMount',
    ]);

So there's a bug somewhere

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jan 29, 2024
@react-sizebot

react-sizebot commented Jan 29, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: 374fd68...4afefce

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.min.js = 176.82 kB 176.82 kB = 55.12 kB 55.12 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 178.81 kB 178.81 kB = 55.70 kB 55.69 kB
facebook-www/ReactDOM-prod.classic.js = 593.39 kB 593.39 kB = 104.69 kB 104.69 kB
facebook-www/ReactDOM-prod.modern.js = 577.17 kB 577.17 kB = 101.78 kB 101.78 kB
test_utils/ReactAllWarnings.js Deleted 67.02 kB 0.00 kB Deleted 16.42 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-art/cjs/react-art.development.js +0.33% 857.41 kB 860.28 kB +0.37% 187.42 kB 188.11 kB
oss-experimental/react-art/umd/react-art.development.js +0.31% 974.49 kB 977.48 kB +0.35% 206.57 kB 207.30 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js +0.30% 957.60 kB 960.47 kB +0.33% 205.96 kB 206.65 kB
oss-experimental/react-dom/cjs/react-dom.development.js +0.21% 1,354.00 kB 1,356.87 kB +0.23% 299.19 kB 299.88 kB
oss-experimental/react-dom/umd/react-dom.development.js +0.21% 1,419.00 kB 1,422.00 kB +0.24% 302.23 kB 302.95 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js +0.21% 1,371.85 kB 1,374.72 kB +0.23% 303.47 kB 304.17 kB
test_utils/ReactAllWarnings.js Deleted 67.02 kB 0.00 kB Deleted 16.42 kB 0.00 kB

Generated by 🚫 dangerJS against 4afefce

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tyao1

tyao1 commented Jan 29, 2024

Copy link
Copy Markdown
Contributor

which causes a stray componentWillUnmount to fire.

Noob question, I don't see a stray componentWillUnmount in after, isn't after the current behavior of StrictMode that double invoke effects?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rickhanlonii
rickhanlonii force-pushed the rh/modern-strict branch from 848cc06 to ed38c95 Compare January 29, 2024 22:59
@rickhanlonii rickhanlonii changed the title [wip] Move modern strict to experimental Move modern strict to experimental Jan 29, 2024
@rickhanlonii

rickhanlonii commented Jan 29, 2024

Copy link
Copy Markdown
Contributor Author

oh wow @tyao1 you're right, i haven't used classes in so long i forgot what the method was called, i was expecting componentDidUnmount oops

tyao1 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rickhanlonii
rickhanlonii force-pushed the rh/modern-strict branch from ed38c95 to 2460666 Compare January 29, 2024 23:07
@rickhanlonii
rickhanlonii marked this pull request as ready for review January 29, 2024 23:11
tyao1
tyao1 approved these changes Jan 29, 2024
View reviewed changes
@rickhanlonii

rickhanlonii commented Jan 30, 2024

Copy link
Copy Markdown
Contributor Author

Yeah I have no idea what that failure is, dev tools seems to error but I cannot figure out how to see what the error is.

@hoxyq are you familiar with this test at all or know how to debug it to see what the error is? I tried and got stuck in test abstraction hell

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hoxyq

hoxyq commented Jan 30, 2024

Copy link
Copy Markdown
Collaborator

Yeah I have no idea what that failure is, dev tools seems to error but I cannot figure out how to see what the error is.

@hoxyq are you familiar with this test at all or know how to debug it to see what the error is? I tried and got stuck in test abstraction hell

Looking into that now

rickhanlonii reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hoxyq

hoxyq commented Jan 30, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

I was able to triage up to this line:
https://github.com/facebook/react/blob/2477384650bd184d3ac4a881130118f2636f8551/packages/react-devtools-shared/src/backend/console.js#L224

Let me share a bit more context whats going on here:

  • React DevTools patches the console methods in order to collect errors and warnings, which will be later displayed on the components tab
  • When ReactDOM.render is called in DEV, it emits the error message Warning: ReactDOM.render is no longer supported in React 18...
  • Before these changes: current fiber is null, there is no work in progress
  • With these changes: current fiber is not null, seems like React is still performing some work, that's why this message from ReactDOM is handled by React DevTools and registered as an error in component (root)

With modern strict and legacy render, the current is not null here, meaning that some work is being performed when ReactDOM.render is called. I don't have any useful knowledge around reconciler, so I don't really know if its expected or why this happens.

Questions:

  • Are modern strict and legacy render (via ReactDOM.render) compatible? If not, then we should gate this test.

Possible reason why this happens:

  • React DevTools still using unstable_act from React and not from 'internal-test-utils'. Plus this is not asynchronous.
  • If you run other test storeStressTestConcurrent-test.js on your branch, it will also have some failing cases. This test uses concurrent rendering, so it definitely should be compatible with modern strict.
    • Possible solution: I've replaced all act calls with await require('internal-test-utils').act(...) and now tests are passing.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hoxyq

hoxyq commented Jan 30, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Next steps for me: I need to validate if migrating DevTools tests to using act from internal-test-utils will solve the issues.

The tricky part here is that DevTools tests are gated for a specific React version:

  • If test is gated for <18 version, we should use act as require('react-dom/test-utils').act
  • If test is gated for >= 18 && <$CURRENT_ON_MAIN, we should use act as require('react').unstable_act
  • If test is not gated (runs on experimental), we should use act as require('internal-test-utils').act

Currently, this is only partially implemented and we don't use internal-test-utils:
https://github.com/facebook/react/blob/2477384650bd184d3ac4a881130118f2636f8551/packages/react-devtools-shared/src/__tests__/utils.js#L22-L24
https://github.com/facebook/react/blob/2477384650bd184d3ac4a881130118f2636f8551/packages/react-devtools-shared/src/__tests__/utils.js#L49-L51

Can this change wait before the end of the week, so I can try to implement this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rickhanlonii

rickhanlonii commented Jan 30, 2024

Copy link
Copy Markdown
Contributor Author

Do you have a sense for why that would work? I can't figure out what the unexpected error actually is, I can only find the error count. If I knew the error, I could tell you if that would fix it.

Based on the changes, I wouldn't expect any new errors (this is only a strict mode change, and these tests don't use strict mode) so I don't expect changing act would fix it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hoxyq

hoxyq commented Jan 31, 2024

Copy link
Copy Markdown
Collaborator

Based on the changes, I wouldn't expect any new errors (this is only a strict mode change, and these tests don't use strict mode) so I don't expect changing act would fix it.

There is more to that, this flag is used in reconciler:
https://github.com/facebook/react/blob/45582c6c4d8b73229c71febbba43ee60fbab81fb/packages/react-reconciler/src/ReactFiberWorkLoop.js#L3706-L3728

Its actually changes the way how current fiber is set in DEV:
https://github.com/facebook/react/blob/45582c6c4d8b73229c71febbba43ee60fbab81fb/packages/react-reconciler/src/ReactFiberWorkLoop.js#L3660

And this is the injected dependency from React into React DevTools (getCurrentFiber), so RDT will know which fiber has just emitted an error. For some reason, if we are using unstable_act from react, the effects invocation phase is not finished and leaves current fiber as non-null, which makes React DevTools think that error was emitted by this fiber.

Maybe there is someone who can explain the reason behind having internal version of act? This should be the answer.
cc @sammy-SC @acdlite

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hoxyq

hoxyq commented Feb 1, 2024

Copy link
Copy Markdown
Collaborator

Okay, I think I found the issue here. React DevTools console patching works incorrectly for this scenario with modern strict mode.

When React DevTools hook is injected, it sets up the callback setStrictMode, which is used by React to notify RDT. When this callback is executed, RDT patches the console.

In this case with modern strict mode, such patching doesn't happen, that is why the error is not properly filtered.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hoxyq

hoxyq commented Feb 1, 2024

Copy link
Copy Markdown
Collaborator

Okay, I think I found the issue here. React DevTools console patching works incorrectly for this scenario with modern strict mode.

When React DevTools hook is injected, it sets up the callback setStrictMode, which is used by React to notify RDT. When this callback is executed, RDT patches the console.

In this case with modern strict mode, such patching doesn't happen, that is why the error is not properly filtered.

Nope, this is not the case here, unfortunately: validated that with legacy strict mode these functions are also not called.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hoxyq hoxyq mentioned this pull request Feb 9, 2024
fix: define IS_ACT_ENVIRONMENT global for tests with concurrent mode and synchronous act #28296
Merged
@rickhanlonii
Move modern strict to experimental
f552806
@rickhanlonii
rickhanlonii force-pushed the rh/modern-strict branch from 2460666 to f552806 Compare February 9, 2024 20:00
rickhanlonii added 2 commits February 9, 2024 15:58
@rickhanlonii
Turn off strict effects in legacy roots with useModernStrictMode
a92a3ac
@rickhanlonii
Legacy mode never double invokes effects
4afefce
rickhanlonii
rickhanlonii commented Feb 9, 2024
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberWorkLoop.js

if (root.tag === LegacyRoot && !(root.current.mode & StrictLegacyMode)) {
doubleInvokeEffects = false;
}

@rickhanlonii rickhanlonii Feb 9, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@sammy-SC @acdlite, I fixed this bug that turned on strict effects in Legacy Mode, which may be the reason it was hard to land internally, breaking unit tests and whatnot.

Previously, legacyCommitDoubleInvokeEffectsInDEV would be called in the legacy root too (when strict mode was on), but we wouldn't fire any effects because no fiber flags were set. When we copied over the check to this block, it forces effects to be fired, since it's not checking fiber flags (by design).

We have a test that caught this, but we didn't have any test variants that enabled useModernStrictMode:

https://github.com/facebook/react/blob/30e2938e04c8cf51688509a457a494d36bcc4269/packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js#L29

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rickhanlonii
rickhanlonii merged commit 06e410e into react:main Feb 9, 2024
@rickhanlonii
rickhanlonii deleted the rh/modern-strict branch February 9, 2024 21:59
This was referenced Feb 20, 2024
Bump vendored react versions vercel/next.js#62302
Closed
Upgrade vendored react vercel/next.js#62326
Merged
huozhi added a commit to vercel/next.js that referenced this pull request Feb 23, 2024
@huozhi
Upgrade vendored react (#62326)
e5d604f
### React upstream changes

- react/react#28333
- react/react#28334
- react/react#28378
- react/react#28377
- react/react#28376
- react/react#28338
- react/react#28331
- react/react#28336
- react/react#28320
- react/react#28317
- react/react#28375
- react/react#28367
- react/react#28380
- react/react#28368
- react/react#28343
- react/react#28355
- react/react#28374
- react/react#28362
- react/react#28344
- react/react#28339
- react/react#28353
- react/react#28346
- react/react#25790
- react/react#28352
- react/react#28326
- react/react#27688
- react/react#28329
- react/react#28332
- react/react#28340
- react/react#28327
- react/react#28325
- react/react#28324
- react/react#28309
- react/react#28310
- react/react#28307
- react/react#28306
- react/react#28315
- react/react#28318
- react/react#28226
- react/react#28308
- react/react#27563
- react/react#28297
- react/react#28286
- react/react#28284
- react/react#28275
- react/react#28145
- react/react#28301
- react/react#28224
- react/react#28152
- react/react#28296
- react/react#28294
- react/react#28279
- react/react#28273
- react/react#28269
- react/react#28376
- react/react#28338
- react/react#28331
- react/react#28336
- react/react#28320
- react/react#28317
- react/react#28375
- react/react#28367
- react/react#28380
- react/react#28368
- react/react#28343
- react/react#28355
- react/react#28374
- react/react#28362
- react/react#28344
- react/react#28339
- react/react#28353
- react/react#28346
- react/react#25790
- react/react#28352
- react/react#28326
- react/react#27688
- react/react#28329
- react/react#28332
- react/react#28340
- react/react#28327
- react/react#28325
- react/react#28324
- react/react#28309
- react/react#28310
- react/react#28307
- react/react#28306
- react/react#28315
- react/react#28318
- react/react#28226
- react/react#28308
- react/react#27563
- react/react#28297
- react/react#28286
- react/react#28284
- react/react#28275
- react/react#28145
- react/react#28301
- react/react#28224
- react/react#28152
- react/react#28296
- react/react#28294
- react/react#28279
- react/react#28273
- react/react#28269

Closes NEXT-2542


Disable ppr test for strict mode for now, @acdlite will check it and
we'll sync again
@ztanner ztanner mentioned this pull request Mar 19, 2024
(backport) Update React from 60a927d04 to 14898b6a9 vercel/next.js#63442
Closed
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
@rickhanlonii @AndyPengc12
Move modern strict to experimental (react#28152)
074de08
Turn this on 

Edited: ope, nvm
<details>
Looks like there's still an outstanding issue with this. The original PR
turned off a strict effects test, which causes a stray
`componentWillUnmount` to fire.


react@5d1ce65#diff-19df471970763c4790c2cc0811fd2726cc6a891b0e1d5dedbf6d0599240c127aR70


Before:
```js
expect(log).toEqual([
      'constructor',
      'constructor',
      'getDerivedStateFromProps',
      'getDerivedStateFromProps',
      'render',
      'render',
      'componentDidMount',
    ]);
```

After:

```js
expect(log).toEqual([
      'constructor',
      'constructor',
      'getDerivedStateFromProps',
      'getDerivedStateFromProps',
      'render',
      'render',
      'componentDidMount',
      'componentWillUnmount',
      'componentDidMount',
    ]);
```

So there's a bug somewhere
</details>
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
@rickhanlonii
Move modern strict to experimental (#28152)
1544bf4
Turn this on

Edited: ope, nvm
<details>
Looks like there's still an outstanding issue with this. The original PR
turned off a strict effects test, which causes a stray
`componentWillUnmount` to fire.

5d1ce65#diff-19df471970763c4790c2cc0811fd2726cc6a891b0e1d5dedbf6d0599240c127aR70

Before:
```js
expect(log).toEqual([
      'constructor',
      'constructor',
      'getDerivedStateFromProps',
      'getDerivedStateFromProps',
      'render',
      'render',
      'componentDidMount',
    ]);
```

After:

```js
expect(log).toEqual([
      'constructor',
      'constructor',
      'getDerivedStateFromProps',
      'getDerivedStateFromProps',
      'render',
      'render',
      'componentDidMount',
      'componentWillUnmount',
      'componentDidMount',
    ]);
```

So there's a bug somewhere
</details>

DiffTrain build for commit 06e410e.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@rickhanlonii
Move modern strict to experimental (react#28152)
0b8f4be
Turn this on 

Edited: ope, nvm
<details>
Looks like there's still an outstanding issue with this. The original PR
turned off a strict effects test, which causes a stray
`componentWillUnmount` to fire.


react@f74ca29#diff-19df471970763c4790c2cc0811fd2726cc6a891b0e1d5dedbf6d0599240c127aR70


Before:
```js
expect(log).toEqual([
      'constructor',
      'constructor',
      'getDerivedStateFromProps',
      'getDerivedStateFromProps',
      'render',
      'render',
      'componentDidMount',
    ]);
```

After:

```js
expect(log).toEqual([
      'constructor',
      'constructor',
      'getDerivedStateFromProps',
      'getDerivedStateFromProps',
      'render',
      'render',
      'componentDidMount',
      'componentWillUnmount',
      'componentDidMount',
    ]);
```

So there's a bug somewhere
</details>
@rickhanlonii rickhanlonii mentioned this pull request Nov 23, 2026
[Legacy Mode] remove StrictEffectsMode and the MountLayoutDev flags #38371
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@tyao1 tyao1 tyao1 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@rickhanlonii @react-sizebot @tyao1 @hoxyq @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.