Skip to content

Commit d320b7a

Browse files
committed
Attaching a ping listener might interrupt the render so instead use a dummy
1 parent 3bea1ba commit d320b7a

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

packages/react-reconciler/src/ReactFiberThenable.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ import type {
1717
import ReactSharedInternals from 'shared/ReactSharedInternals';
1818
const {ReactCurrentActQueue} = ReactSharedInternals;
1919

20-
import {
21-
getWorkInProgressRoot,
22-
getWorkInProgressRootRenderLanes,
23-
attachPingListener,
24-
} from './ReactFiberWorkLoop';
25-
2620
export opaque type ThenableState = Array<Thenable<any>>;
2721

2822
// An error that is thrown (e.g. by `use`) to trigger Suspense. If we
@@ -94,6 +88,9 @@ export function trackUsedThenable<T>(
9488
// Only instrument the thenable if the status if not defined. If
9589
// it's defined, but an unknown value, assume it's been instrumented by
9690
// some custom userspace implementation. We treat it as "pending".
91+
// Attach a dummy listener, to ensure that any lazy initialization can
92+
// happen. Flight lazily parses JSON when the value is actually awaited.
93+
thenable.then(noop, noop);
9794
} else {
9895
const pendingThenable: PendingThenable<T> = (thenable: any);
9996
pendingThenable.status = 'pending';
@@ -115,12 +112,6 @@ export function trackUsedThenable<T>(
115112
);
116113
}
117114

118-
// Attach ping listeners eagerly in case this synchronously resolves.
119-
const root = getWorkInProgressRoot();
120-
if (root) {
121-
attachPingListener(root, thenable, getWorkInProgressRootRenderLanes());
122-
}
123-
124115
// Check one more time in case the thenable resolved synchronously.
125116
switch (thenable.status) {
126117
case 'fulfilled': {

0 commit comments

Comments
 (0)