Skip to content

Commit adc2116

Browse files
committed
flags: make enableAsyncDebugInfo dynamic for www (#34430)
As titled. This adds dev-only debugging information to Fizz / Flight that could be used for tracking Promise's stack traces in "suspended by" section of DevTools. DiffTrain build for [c552618](c552618)
1 parent c4d4bc1 commit adc2116

35 files changed

+441
-161
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
df38ac9a3b9a5ea43c1d07c00d090a448acfd56c
1+
c552618a8203866a8bf80324f6efa708d4bdb146
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
df38ac9a3b9a5ea43c1d07c00d090a448acfd56c
1+
c552618a8203866a8bf80324f6efa708d4bdb146

compiled/facebook-www/React-dev.classic.js

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,12 @@ __DEV__ &&
536536
}
537537
function lazyInitializer(payload) {
538538
if (-1 === payload._status) {
539-
var ctor = payload._result,
540-
thenable = ctor();
539+
if (enableAsyncDebugInfo) {
540+
var ioInfo = payload._ioInfo;
541+
null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
542+
}
543+
ioInfo = payload._result;
544+
var thenable = ioInfo();
541545
thenable.then(
542546
function (moduleObject) {
543547
if (0 === payload._status || -1 === payload._status) {
@@ -552,26 +556,43 @@ __DEV__ &&
552556
},
553557
function (error) {
554558
if (0 === payload._status || -1 === payload._status)
555-
(payload._status = 2), (payload._result = error);
559+
if (
560+
((payload._status = 2),
561+
(payload._result = error),
562+
enableAsyncDebugInfo)
563+
) {
564+
var _ioInfo2 = payload._ioInfo;
565+
null != _ioInfo2 && (_ioInfo2.end = performance.now());
566+
void 0 === thenable.status &&
567+
((thenable.status = "rejected"), (thenable.reason = error));
568+
}
556569
}
557570
);
571+
if (
572+
enableAsyncDebugInfo &&
573+
((ioInfo = payload._ioInfo), null != ioInfo)
574+
) {
575+
ioInfo.value = thenable;
576+
var displayName = thenable.displayName;
577+
"string" === typeof displayName && (ioInfo.name = displayName);
578+
}
558579
-1 === payload._status &&
559580
((payload._status = 0), (payload._result = thenable));
560581
}
561582
if (1 === payload._status)
562583
return (
563-
(ctor = payload._result),
564-
void 0 === ctor &&
584+
(ioInfo = payload._result),
585+
void 0 === ioInfo &&
565586
console.error(
566587
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",
567-
ctor
588+
ioInfo
568589
),
569-
"default" in ctor ||
590+
"default" in ioInfo ||
570591
console.error(
571592
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
572-
ctor
593+
ioInfo
573594
),
574-
ctor.default
595+
ioInfo.default
575596
);
576597
throw payload._result;
577598
}
@@ -744,7 +765,8 @@ __DEV__ &&
744765
var dynamicFeatureFlags = require("ReactFeatureFlags"),
745766
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
746767
renameElementSymbol = dynamicFeatureFlags.renameElementSymbol,
747-
enableViewTransition = dynamicFeatureFlags.enableViewTransition;
768+
enableViewTransition = dynamicFeatureFlags.enableViewTransition,
769+
enableAsyncDebugInfo = dynamicFeatureFlags.enableAsyncDebugInfo;
748770
dynamicFeatureFlags = Symbol.for("react.element");
749771
var REACT_ELEMENT_TYPE = renameElementSymbol
750772
? Symbol.for("react.transitional.element")
@@ -1285,11 +1307,26 @@ __DEV__ &&
12851307
);
12861308
};
12871309
exports.lazy = function (ctor) {
1288-
return {
1310+
ctor = { _status: -1, _result: ctor };
1311+
var lazyType = {
12891312
$$typeof: REACT_LAZY_TYPE,
1290-
_payload: { _status: -1, _result: ctor },
1313+
_payload: ctor,
12911314
_init: lazyInitializer
12921315
};
1316+
if (enableAsyncDebugInfo) {
1317+
var ioInfo = {
1318+
name: "lazy",
1319+
start: -1,
1320+
end: -1,
1321+
value: null,
1322+
owner: null,
1323+
debugStack: Error("react-stack-top-frame"),
1324+
debugTask: console.createTask ? console.createTask("lazy()") : null
1325+
};
1326+
ctor._ioInfo = ioInfo;
1327+
lazyType._debugInfo = [{ awaited: ioInfo }];
1328+
}
1329+
return lazyType;
12931330
};
12941331
exports.memo = function (type, compare) {
12951332
null == type &&
@@ -1421,7 +1458,7 @@ __DEV__ &&
14211458
exports.useTransition = function () {
14221459
return resolveDispatcher().useTransition();
14231460
};
1424-
exports.version = "19.2.0-www-classic-df38ac9a-20250926";
1461+
exports.version = "19.2.0-www-classic-c552618a-20250926";
14251462
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14261463
"function" ===
14271464
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,12 @@ __DEV__ &&
536536
}
537537
function lazyInitializer(payload) {
538538
if (-1 === payload._status) {
539-
var ctor = payload._result,
540-
thenable = ctor();
539+
if (enableAsyncDebugInfo) {
540+
var ioInfo = payload._ioInfo;
541+
null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
542+
}
543+
ioInfo = payload._result;
544+
var thenable = ioInfo();
541545
thenable.then(
542546
function (moduleObject) {
543547
if (0 === payload._status || -1 === payload._status) {
@@ -552,26 +556,43 @@ __DEV__ &&
552556
},
553557
function (error) {
554558
if (0 === payload._status || -1 === payload._status)
555-
(payload._status = 2), (payload._result = error);
559+
if (
560+
((payload._status = 2),
561+
(payload._result = error),
562+
enableAsyncDebugInfo)
563+
) {
564+
var _ioInfo2 = payload._ioInfo;
565+
null != _ioInfo2 && (_ioInfo2.end = performance.now());
566+
void 0 === thenable.status &&
567+
((thenable.status = "rejected"), (thenable.reason = error));
568+
}
556569
}
557570
);
571+
if (
572+
enableAsyncDebugInfo &&
573+
((ioInfo = payload._ioInfo), null != ioInfo)
574+
) {
575+
ioInfo.value = thenable;
576+
var displayName = thenable.displayName;
577+
"string" === typeof displayName && (ioInfo.name = displayName);
578+
}
558579
-1 === payload._status &&
559580
((payload._status = 0), (payload._result = thenable));
560581
}
561582
if (1 === payload._status)
562583
return (
563-
(ctor = payload._result),
564-
void 0 === ctor &&
584+
(ioInfo = payload._result),
585+
void 0 === ioInfo &&
565586
console.error(
566587
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",
567-
ctor
588+
ioInfo
568589
),
569-
"default" in ctor ||
590+
"default" in ioInfo ||
570591
console.error(
571592
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
572-
ctor
593+
ioInfo
573594
),
574-
ctor.default
595+
ioInfo.default
575596
);
576597
throw payload._result;
577598
}
@@ -744,7 +765,8 @@ __DEV__ &&
744765
var dynamicFeatureFlags = require("ReactFeatureFlags"),
745766
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
746767
renameElementSymbol = dynamicFeatureFlags.renameElementSymbol,
747-
enableViewTransition = dynamicFeatureFlags.enableViewTransition;
768+
enableViewTransition = dynamicFeatureFlags.enableViewTransition,
769+
enableAsyncDebugInfo = dynamicFeatureFlags.enableAsyncDebugInfo;
748770
dynamicFeatureFlags = Symbol.for("react.element");
749771
var REACT_ELEMENT_TYPE = renameElementSymbol
750772
? Symbol.for("react.transitional.element")
@@ -1285,11 +1307,26 @@ __DEV__ &&
12851307
);
12861308
};
12871309
exports.lazy = function (ctor) {
1288-
return {
1310+
ctor = { _status: -1, _result: ctor };
1311+
var lazyType = {
12891312
$$typeof: REACT_LAZY_TYPE,
1290-
_payload: { _status: -1, _result: ctor },
1313+
_payload: ctor,
12911314
_init: lazyInitializer
12921315
};
1316+
if (enableAsyncDebugInfo) {
1317+
var ioInfo = {
1318+
name: "lazy",
1319+
start: -1,
1320+
end: -1,
1321+
value: null,
1322+
owner: null,
1323+
debugStack: Error("react-stack-top-frame"),
1324+
debugTask: console.createTask ? console.createTask("lazy()") : null
1325+
};
1326+
ctor._ioInfo = ioInfo;
1327+
lazyType._debugInfo = [{ awaited: ioInfo }];
1328+
}
1329+
return lazyType;
12931330
};
12941331
exports.memo = function (type, compare) {
12951332
null == type &&
@@ -1421,7 +1458,7 @@ __DEV__ &&
14211458
exports.useTransition = function () {
14221459
return resolveDispatcher().useTransition();
14231460
};
1424-
exports.version = "19.2.0-www-modern-df38ac9a-20250926";
1461+
exports.version = "19.2.0-www-modern-c552618a-20250926";
14251462
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14261463
"function" ===
14271464
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,4 +604,4 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.2.0-www-classic-df38ac9a-20250926";
607+
exports.version = "19.2.0-www-classic-c552618a-20250926";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,4 +604,4 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.2.0-www-modern-df38ac9a-20250926";
607+
exports.version = "19.2.0-www-modern-c552618a-20250926";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ exports.useSyncExternalStore = function (
608608
exports.useTransition = function () {
609609
return ReactSharedInternals.H.useTransition();
610610
};
611-
exports.version = "19.2.0-www-classic-df38ac9a-20250926";
611+
exports.version = "19.2.0-www-classic-c552618a-20250926";
612612
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
613613
"function" ===
614614
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ exports.useSyncExternalStore = function (
608608
exports.useTransition = function () {
609609
return ReactSharedInternals.H.useTransition();
610610
};
611-
exports.version = "19.2.0-www-modern-df38ac9a-20250926";
611+
exports.version = "19.2.0-www-modern-c552618a-20250926";
612612
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
613613
"function" ===
614614
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3730,6 +3730,24 @@ __DEV__ &&
37303730
)),
37313731
thenable.then(noop, noop),
37323732
(thenable = index));
3733+
if (enableAsyncDebugInfo && void 0 === thenable._debugInfo) {
3734+
thenableState = performance.now();
3735+
trackedThenables = thenable.displayName;
3736+
var ioInfo = {
3737+
name:
3738+
"string" === typeof trackedThenables ? trackedThenables : "Promise",
3739+
start: thenableState,
3740+
end: thenableState,
3741+
value: thenable
3742+
};
3743+
thenable._debugInfo = [{ awaited: ioInfo }];
3744+
"fulfilled" !== thenable.status &&
3745+
"rejected" !== thenable.status &&
3746+
((thenableState = function () {
3747+
ioInfo.end = performance.now();
3748+
}),
3749+
thenable.then(thenableState, thenableState));
3750+
}
37333751
switch (thenable.status) {
37343752
case "fulfilled":
37353753
return thenable.value;
@@ -17998,6 +18016,7 @@ __DEV__ &&
1799818016
enableComponentPerformanceTrack =
1799918017
dynamicFeatureFlags.enableComponentPerformanceTrack,
1800018018
enableFragmentRefs = dynamicFeatureFlags.enableFragmentRefs,
18019+
enableAsyncDebugInfo = dynamicFeatureFlags.enableAsyncDebugInfo,
1800118020
enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler,
1800218021
REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
1800318022
REACT_ELEMENT_TYPE = renameElementSymbol
@@ -20224,10 +20243,10 @@ __DEV__ &&
2022420243
(function () {
2022520244
var internals = {
2022620245
bundleType: 1,
20227-
version: "19.2.0-www-classic-df38ac9a-20250926",
20246+
version: "19.2.0-www-classic-c552618a-20250926",
2022820247
rendererPackageName: "react-art",
2022920248
currentDispatcherRef: ReactSharedInternals,
20230-
reconcilerVersion: "19.2.0-www-classic-df38ac9a-20250926"
20249+
reconcilerVersion: "19.2.0-www-classic-c552618a-20250926"
2023120250
};
2023220251
internals.overrideHookState = overrideHookState;
2023320252
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -20261,7 +20280,7 @@ __DEV__ &&
2026120280
exports.Shape = Shape;
2026220281
exports.Surface = Surface;
2026320282
exports.Text = Text;
20264-
exports.version = "19.2.0-www-classic-df38ac9a-20250926";
20283+
exports.version = "19.2.0-www-classic-c552618a-20250926";
2026520284
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2026620285
"function" ===
2026720286
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.modern.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3636,6 +3636,24 @@ __DEV__ &&
36363636
)),
36373637
thenable.then(noop, noop),
36383638
(thenable = index));
3639+
if (enableAsyncDebugInfo && void 0 === thenable._debugInfo) {
3640+
thenableState = performance.now();
3641+
trackedThenables = thenable.displayName;
3642+
var ioInfo = {
3643+
name:
3644+
"string" === typeof trackedThenables ? trackedThenables : "Promise",
3645+
start: thenableState,
3646+
end: thenableState,
3647+
value: thenable
3648+
};
3649+
thenable._debugInfo = [{ awaited: ioInfo }];
3650+
"fulfilled" !== thenable.status &&
3651+
"rejected" !== thenable.status &&
3652+
((thenableState = function () {
3653+
ioInfo.end = performance.now();
3654+
}),
3655+
thenable.then(thenableState, thenableState));
3656+
}
36393657
switch (thenable.status) {
36403658
case "fulfilled":
36413659
return thenable.value;
@@ -17774,6 +17792,7 @@ __DEV__ &&
1777417792
enableComponentPerformanceTrack =
1777517793
dynamicFeatureFlags.enableComponentPerformanceTrack,
1777617794
enableFragmentRefs = dynamicFeatureFlags.enableFragmentRefs,
17795+
enableAsyncDebugInfo = dynamicFeatureFlags.enableAsyncDebugInfo,
1777717796
enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler,
1777817797
REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
1777917798
REACT_ELEMENT_TYPE = renameElementSymbol
@@ -19995,10 +20014,10 @@ __DEV__ &&
1999520014
(function () {
1999620015
var internals = {
1999720016
bundleType: 1,
19998-
version: "19.2.0-www-modern-df38ac9a-20250926",
20017+
version: "19.2.0-www-modern-c552618a-20250926",
1999920018
rendererPackageName: "react-art",
2000020019
currentDispatcherRef: ReactSharedInternals,
20001-
reconcilerVersion: "19.2.0-www-modern-df38ac9a-20250926"
20020+
reconcilerVersion: "19.2.0-www-modern-c552618a-20250926"
2000220021
};
2000320022
internals.overrideHookState = overrideHookState;
2000420023
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -20032,7 +20051,7 @@ __DEV__ &&
2003220051
exports.Shape = Shape;
2003320052
exports.Surface = Surface;
2003420053
exports.Text = Text;
20035-
exports.version = "19.2.0-www-modern-df38ac9a-20250926";
20054+
exports.version = "19.2.0-www-modern-c552618a-20250926";
2003620055
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2003720056
"function" ===
2003820057
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)