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

Fix: Stylesheet in error UI suspends indefinitely #27265

Merged
merged 1 commit into from
Aug 22, 2023

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Aug 22, 2023

This fixes the regression test added in the previous commit. The "Suspensey commit" implementation relies on the shouldRemainOnPreviousScreen function to determine whether to 1) suspend the commit 2) activate a parent fallback and schedule a retry. The issue was that we were sometimes attempting option 2 even when there was no parent fallback.

Part of the reason this bug landed is due to how throwException is structured. In the case of Suspensey commits, we pass a special "noop" thenable to throwException as a way to trigger the Suspense path. This special thenable must never have a listener attached to it. This is not a great way to structure the logic, it's just a consequence of how the code evolved over time. We should refactor it into multiple functions so we can trigger a fallback directly without having to check the type. In the meantime, I added an internal warning to help detect similar mistakes in the future.

@acdlite acdlite requested a review from gnoff August 22, 2023 15:01
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Aug 22, 2023
);
}
}
// We only attach ping listeners in concurrent mode. Legacy Suspense always
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved this into the branches above to avoid attaching a redundant listener to the "noop" thenable. That way we can treat any listener that does get attached as a mistake and warn in dev.

// NOTE: We do this even for sync updates, for lack of any better option. In
// the future, we may change how we handle this, like by putting the whole
// root into a "detached" mode.
return true;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the actual fix. It used to return false in this case, now it returns true.

@react-sizebot
Copy link

react-sizebot commented Aug 22, 2023

Comparing: e76a5ac...b7cf5ba

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 = 165.67 kB 165.59 kB = 51.99 kB 51.88 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 173.16 kB 173.15 kB = 54.21 kB 54.20 kB
facebook-www/ReactDOM-prod.classic.js = 570.50 kB 569.82 kB = 100.49 kB 100.37 kB
facebook-www/ReactDOM-prod.modern.js = 554.30 kB 553.62 kB = 97.66 kB 97.53 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against b7cf5ba

This fixes the regression test added in the previous commit. The "Suspensey
commit" implementation relies on the `shouldRemainOnPreviousScreen` function to
determine whether to 1) suspend the commit 2) activate a parent fallback and
schedule a retry. The issue was that we were sometimes attempting option 2 even
when there was no parent fallback.

Part of the reason this bug landed is due to how `throwException` is structured.
In the case of Suspensey commits, we pass a special "noop" thenable to
`throwException` as a way to trigger the Suspense path. This special thenable
must never have a listener attached to it. This is not a great way to structure
the logic, it's just a consequence of how the code evolved over time. We should
refactor it into multiple functions so we can trigger a fallback directly
without having to check the type. In the meantime, I added an internal warning
to help detect similar mistakes in the future.
@acdlite acdlite force-pushed the fix-stylesheet-in-error-ui branch from 00090a8 to b7cf5ba Compare August 22, 2023 15:16
@acdlite acdlite merged commit dd480ef into facebook:main Aug 22, 2023
github-actions bot pushed a commit that referenced this pull request Aug 22, 2023
This fixes the regression test added in the previous commit. The
"Suspensey commit" implementation relies on the
`shouldRemainOnPreviousScreen` function to determine whether to 1)
suspend the commit 2) activate a parent fallback and schedule a retry.
The issue was that we were sometimes attempting option 2 even when there
was no parent fallback.

Part of the reason this bug landed is due to how `throwException` is
structured. In the case of Suspensey commits, we pass a special "noop"
thenable to `throwException` as a way to trigger the Suspense path. This
special thenable must never have a listener attached to it. This is not
a great way to structure the logic, it's just a consequence of how the
code evolved over time. We should refactor it into multiple functions so
we can trigger a fallback directly without having to check the type. In
the meantime, I added an internal warning to help detect similar
mistakes in the future.

DiffTrain build for [dd480ef](dd480ef)
kodiakhq bot pushed a commit to vercel/next.js that referenced this pull request Aug 23, 2023
### Problem

One style of `not-found` has `precendence` property with "undefined" value, which can't be handled by React Float, then during navigation the style could not load properly, lead to the style missing in issue #53210.

### Solution

Always enable `precendence` for all links, so all the css styles of page and convention components can be hoist by react properly. Float will decide which one should be handled. Previously this change only applies to template, actually we can apply it to all components so that they can all be handled properly especially during client navigation.

Related react change: facebook/react#27265
Fixes #53210
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
This fixes the regression test added in the previous commit. The
"Suspensey commit" implementation relies on the
`shouldRemainOnPreviousScreen` function to determine whether to 1)
suspend the commit 2) activate a parent fallback and schedule a retry.
The issue was that we were sometimes attempting option 2 even when there
was no parent fallback.

Part of the reason this bug landed is due to how `throwException` is
structured. In the case of Suspensey commits, we pass a special "noop"
thenable to `throwException` as a way to trigger the Suspense path. This
special thenable must never have a listener attached to it. This is not
a great way to structure the logic, it's just a consequence of how the
code evolved over time. We should refactor it into multiple functions so
we can trigger a fallback directly without having to check the type. In
the meantime, I added an internal warning to help detect similar
mistakes in the future.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
This fixes the regression test added in the previous commit. The
"Suspensey commit" implementation relies on the
`shouldRemainOnPreviousScreen` function to determine whether to 1)
suspend the commit 2) activate a parent fallback and schedule a retry.
The issue was that we were sometimes attempting option 2 even when there
was no parent fallback.

Part of the reason this bug landed is due to how `throwException` is
structured. In the case of Suspensey commits, we pass a special "noop"
thenable to `throwException` as a way to trigger the Suspense path. This
special thenable must never have a listener attached to it. This is not
a great way to structure the logic, it's just a consequence of how the
code evolved over time. We should refactor it into multiple functions so
we can trigger a fallback directly without having to check the type. In
the meantime, I added an internal warning to help detect similar
mistakes in the future.

DiffTrain build for commit dd480ef.
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.

4 participants