Skip to content

Commit 314f7d3

Browse files
committed
Revert "[Float] Suspend unstyled content for up to 1 minute (#26532)"
This reverts commit 0ae3480.
1 parent adac7b1 commit 314f7d3

File tree

2 files changed

+17
-38
lines changed

2 files changed

+17
-38
lines changed

packages/react-dom-bindings/src/client/ReactDOMHostConfig.js

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,34 +3333,28 @@ export function waitForCommitToBeReady(): null | (Function => Function) {
33333333
// tasks to wait on.
33343334
if (state.count > 0) {
33353335
return commit => {
3336-
// We almost never want to show content before its styles have loaded. But
3337-
// eventually we will give up and allow unstyled content. So this number is
3338-
// somewhat arbitrary — big enough that you'd only reach it under
3339-
// extreme circumstances.
3340-
// TODO: Figure out what the browser engines do during initial page load and
3341-
// consider aligning our behavior with that.
3342-
const stylesheetTimer = setTimeout(() => {
3343-
if (state.stylesheets) {
3344-
insertSuspendedStylesheets(state, state.stylesheets);
3345-
}
3346-
if (state.unsuspend) {
3347-
const unsuspend = state.unsuspend;
3348-
state.unsuspend = null;
3349-
unsuspend();
3350-
}
3351-
}, 60000); // one minute
3352-
3336+
unsuspendAfterTimeout(state);
33533337
state.unsuspend = commit;
33543338

3355-
return () => {
3356-
state.unsuspend = null;
3357-
clearTimeout(stylesheetTimer);
3358-
};
3339+
return () => (state.unsuspend = null);
33593340
};
33603341
}
33613342
return null;
33623343
}
33633344

3345+
function unsuspendAfterTimeout(state: SuspendedState) {
3346+
setTimeout(() => {
3347+
if (state.stylesheets) {
3348+
insertSuspendedStylesheets(state, state.stylesheets);
3349+
}
3350+
if (state.unsuspend) {
3351+
const unsuspend = state.unsuspend;
3352+
state.unsuspend = null;
3353+
unsuspend();
3354+
}
3355+
}, 500);
3356+
}
3357+
33643358
function onUnsuspend(this: SuspendedState) {
33653359
this.count--;
33663360
if (this.count === 0) {

packages/react-dom/src/__tests__/ReactDOMFloat-test.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,7 +3163,7 @@ body {
31633163
);
31643164
});
31653165

3166-
it('stylesheets block render, with a really long timeout', async () => {
3166+
it('can unsuspend after a timeout even if some assets never load', async () => {
31673167
function App({children}) {
31683168
return (
31693169
<html>
@@ -3191,22 +3191,7 @@ body {
31913191
</html>,
31923192
);
31933193

3194-
// Advance time by 50 seconds. Even still, the transition is suspended.
3195-
jest.advanceTimersByTime(50000);
3196-
await waitForAll([]);
3197-
expect(getMeaningfulChildren(document)).toEqual(
3198-
<html>
3199-
<head>
3200-
<link rel="preload" href="foo" as="style" />
3201-
</head>
3202-
<body />
3203-
</html>,
3204-
);
3205-
3206-
// Advance time by 10 seconds more. A full minute total has elapsed. At this
3207-
// point, something must have really gone wrong, so we time out and allow
3208-
// unstyled content to be displayed.
3209-
jest.advanceTimersByTime(10000);
3194+
jest.advanceTimersByTime(1000);
32103195
expect(getMeaningfulChildren(document)).toEqual(
32113196
<html>
32123197
<head>

0 commit comments

Comments
 (0)