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 — Fix for failed Suspense layout semantics by bvaughn · Pull Request #21694 · react/react

Conversation

@bvaughn

@bvaughn bvaughn commented Jun 16, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Resolves #21676. Fixes failing test added in #21677

When adding the new Suspense/Offscreen effects semantics, we intentionally left out the subtreeFlags checks since these values aren't 100% reliable and the check is just an optimization. (Refer to the // TODO (Offscreen) comments in the source code.)

It looks like #21386 (re)added one though, which was causing a failure case originally reported here:
reactwg/react-18#31

For now, this PR just removes that check and adds a follow up TODO comment. This is just a bandaid fix to allow us to resume rolling out the new Suspense layout semantics. A proper long-term fix would be to identify why the subtreeFlags are incorrect in this case.

Sorry, something went wrong.

Uh oh!

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

All reactions
gaearon and others added 2 commits June 16, 2021 09:47
@gaearon Brian Vaughn
Add failing test for Suspense layout semantics
a5e8ce3
Brian Vaughn
Removed subtreeFlags check from commitLayoutEffects_begin()
d90747d
This was preventing layout effects from being recreated within Offscreen subtrees in some conditions.
@bvaughn
bvaughn requested review from acdlite and gaearon June 16, 2021 17:41
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jun 16, 2021
@bvaughn bvaughn mentioned this pull request Jun 16, 2021
Add failing test for Suspense layout semantics #21677
Closed
@bvaughn bvaughn changed the title Add failing test for Suspense layout semantics Fix for failed Suspense layout semantics Jun 16, 2021
gaearon
gaearon approved these changes Jun 16, 2021
View reviewed changes

@gaearon gaearon left a comment

Copy link
Copy Markdown
Collaborator

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.

Beautiful. Thank you.

Sorry, something went wrong.

Uh oh!

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

All reactions
@sizebot

sizebot commented Jun 16, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Comparing: a0d2d1e...742d0b0

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 = 127.40 kB 127.34 kB = 40.83 kB 40.82 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 130.21 kB 130.16 kB = 41.73 kB 41.73 kB
facebook-www/ReactDOM-prod.classic.js = 405.89 kB 405.75 kB = 75.02 kB 75.02 kB
facebook-www/ReactDOM-prod.modern.js = 394.32 kB 394.18 kB = 73.24 kB 73.24 kB
facebook-www/ReactDOMForked-prod.classic.js = 405.89 kB 405.75 kB = 75.03 kB 75.03 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 742d0b0

All reactions

Sorry, something went wrong.

Uh oh!

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

@bvaughn

bvaughn commented Jun 16, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

That's interesting. We have a slight timing difference for when we destroy the layout effect in production tests too.

ReactTestRenderer.act(() => {
  _setShow(true);
});
expect(Scheduler).toHaveYielded([
  "Child 1",
  "Suspend! [Child 2]",
  "Loading...",
  // In development we destroy it here
  "destroy layout",
]);
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded([
  // In production we destroy it here
  "destroy layout",
  "Promise resolved [Child 2]",
]);

I'm not sure why there's a difference in these two behaviors. I would not expect there to be. Looking at the stack, I see the following frames in DEV mode:

  at commitRoot (packages/react-reconciler/src/ReactFiberWorkLoop.new.js:1696:5)
  at finishConcurrentRender (packages/react-reconciler/src/ReactFiberWorkLoop.new.js:930:9)
  at performConcurrentWorkOnRoot (packages/react-reconciler/src/ReactFiberWorkLoop.new.js:820:5)
  at workLoop (packages/scheduler/src/forks/SchedulerMock.js:188:34)
  at flushWork (packages/scheduler/src/forks/SchedulerMock.js:141:16)
  at unstable_flushAllWithoutAsserting (packages/scheduler/src/forks/SchedulerMock.js:531:23)
  at flushActWork (packages/react-reconciler/src/ReactFiberWorkLoop.new.js:2948:14)

But in production mode I see:

  at commitRoot (packages/react-reconciler/src/ReactFiberWorkLoop.new.js:1696:5)
  at callback (node_modules/@jest/fake-timers/build/legacyFakeTimers.js:565:32)
  at FakeTimers._runTimerHandle (node_modules/@jest/fake-timers/build/legacyFakeTimers.js:601:9)
  at FakeTimers.advanceTimersByTime (node_modules/@jest/fake-timers/build/legacyFakeTimers.js:292:14)

So for some reason, it looks like commitRoot is being deferred behind a setTimeout in the prod tests.

In Dev, higher up in the call stack is finishConcurrentRender, which checks shouldForceFlushFallbacksInDEV(). So this is probably the difference. Kind of unfortunate that it manifests itself in an observably different way like this huh.

All reactions

Sorry, something went wrong.

Uh oh!

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

Brian Vaughn
Updated test to account for DEV/prod differences
742d0b0
@bvaughn
bvaughn merged commit d0f348d into react:master Jun 16, 2021
@bvaughn
bvaughn deleted the issues/21676 branch June 16, 2021 23:44
@gaearon gaearon mentioned this pull request Jun 17, 2021
Fix failing test #21697
Merged
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Jun 22, 2021
@kacieb @facebook-github-bot
React Native sync for revisions c96b78e...568dc35
d4d22fb
Summary:
This sync includes the following changes:
- **[43f4cc1](react/react@43f4cc160 )**: Fix failing test ([#21697](react/react#21697)) //<Dan Abramov>//
- **[d0f348d](react/react@d0f348dc1 )**: Fix for failed Suspense layout semantics ([#21694](react/react#21694)) //<Brian Vaughn>//
- **[bd0a963](react/react@bd0a96344 )**: Throw when `act` is used in production ([#21686](react/react#21686)) //<Andrew Clark>//
- **[9343f87](react/react@9343f8720 )**: Use the server src files as entry points for the builds/tests ([#21683](react/react#21683)) //<Sebastian Markbåge>//
- **[502f8a2](react/react@502f8a2a0 )**: [Fizz/Flight] Don't use default args ([#21681](react/react#21681)) //<Sebastian Markbåge>//
- **[a8f5e77](react/react@a8f5e77b9 )**: Remove invokeGuardedCallback from commit phase ([#21666](react/react#21666)) //<Dan Abramov>//
- **[dbe3363](react/react@dbe3363cc )**: [Fizz] Implement Legacy renderToString and renderToNodeStream on top of Fizz ([#21276](react/react#21276)) //<Sebastian Markbåge>//
- **[101ea9f](react/react@101ea9f55 )**: Set deletedTreeCleanUpLevel to 3 ([#21679](react/react#21679)) //<Dan Abramov>//
- **[1a106bd](react/react@1a106bdc2 )**: Wrap eventhandle-specific logic in a flag ([#21657](react/react#21657)) //<Dan Abramov>//
- **[cb30388](react/react@cb30388d1 )**: Export React Native `AttributeType` Types ([#21661](react/react#21661)) //<Timothy Yung>//
- **[c153679](react/react@c1536795c )**: Revert "Make enableSuspenseLayoutEffectSemantics static for www ([#21617](react/react#21617))" ([#21656](react/react#21656)) //<Sebastian Markbåge>//

Changelog:
[General][Changed] - React Native sync for revisions c96b78e...568dc35

jest_e2e[run_all_tests]

Reviewed By: rickhanlonii

Differential Revision: D29303157

fbshipit-source-id: 90952885eb2264f4effa04070357b80700bb9be3
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
Brian Vaughn @gaearon
Fix for failed Suspense layout semantics (react#21694)
6c59c91
Co-authored-by: Dan Abramov <[email protected]>
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
Brian Vaughn @gaearon
Fix for failed Suspense layout semantics (react#21694)
49fea23
Co-authored-by: Dan Abramov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gaearon gaearon gaearon approved these changes
@acdlite acdlite Awaiting requested review from acdlite

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.

Bug: Layout effects don't re-fire in 18 on Suspense re-showing

Uh oh!

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

4 participants

@bvaughn @sizebot @gaearon @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.