Skip to content

Commit

Permalink
[Fiber] Stash ThenableState on the Dependencies Object for Use By Dev…
Browse files Browse the repository at this point in the history
…Tools (#30866)

This lets us track what a Component might suspend on from DevTools. We
could already collect this by replaying a component's Hooks but that
would be expensive to collect from a whole tree.

The thenables themselves might contain useful information but mainly
we'd want access to the `_debugInfo` on the thenables which might
contain additional information from the server.

https://github.com/facebook/react/blob/19bd26beb689e554fceb0b929dc5199be8cba594/packages/shared/ReactTypes.js#L114

In a follow up we should really do something similar in Flight to
transfer `use()` on the debugInfo of that Server Component.

DiffTrain build for commit 8d68da3.
  • Loading branch information
sebmarkbage committed Sep 3, 2024
1 parent 3ba4b12 commit 18e907e
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 53 deletions.
2 changes: 1 addition & 1 deletion compiled-rn/VERSION_NATIVE_FB
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.0.0-native-fb-246d7bfe-20240826
19.0.0-native-fb-8d68da3f-20240903
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9fd63ef3b1c7300e9c6d203ae91a8b08>>
* @generated SignedSource<<f2db4f138a96e7535db3c704161f2a6d>>
*/

"use strict";
Expand Down Expand Up @@ -3676,6 +3676,14 @@ __DEV__ &&
}
function finishRenderingHooks(current, workInProgress) {
workInProgress._debugHookTypes = hookTypesDev;
null === workInProgress.dependencies
? null !== thenableState &&
(workInProgress.dependencies = {
lanes: 0,
firstContext: null,
_debugThenableState: thenableState
})
: (workInProgress.dependencies._debugThenableState = thenableState);
ReactSharedInternals.H = ContextOnlyDispatcher;
var didRenderTooFewHooks =
null !== currentHook && null !== currentHook.next;
Expand Down Expand Up @@ -7796,7 +7804,11 @@ __DEV__ &&
"Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()."
);
lastContextDependency = context;
consumer.dependencies = { lanes: 0, firstContext: context };
consumer.dependencies = {
lanes: 0,
firstContext: context,
_debugThenableState: null
};
} else lastContextDependency = lastContextDependency.next = context;
return value;
}
Expand Down Expand Up @@ -12230,7 +12242,8 @@ __DEV__ &&
? null
: {
lanes: pendingProps.lanes,
firstContext: pendingProps.firstContext
firstContext: pendingProps.firstContext,
_debugThenableState: pendingProps._debugThenableState
};
workInProgress.sibling = current.sibling;
workInProgress.index = current.index;
Expand Down Expand Up @@ -12283,7 +12296,8 @@ __DEV__ &&
? null
: {
lanes: renderLanes.lanes,
firstContext: renderLanes.firstContext
firstContext: renderLanes.firstContext,
_debugThenableState: renderLanes._debugThenableState
}),
(workInProgress.selfBaseDuration = current.selfBaseDuration),
(workInProgress.treeBaseDuration = current.treeBaseDuration));
Expand Down Expand Up @@ -14938,11 +14952,11 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.0.0-native-fb-246d7bfe-20240826",
version: "19.0.0-native-fb-8d68da3f-20240903",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-246d7bfe-20240826"
reconcilerVersion: "19.0.0-native-fb-8d68da3f-20240903"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -15087,5 +15101,5 @@ __DEV__ &&
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.0.0-native-fb-246d7bfe-20240826";
exports.version = "19.0.0-native-fb-8d68da3f-20240903";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<c126df2e448ffc59e98d891cf74ae8d2>>
* @generated SignedSource<<8ab9ee6b60c4927fc87658452c1ef8e1>>
*/

"use strict";
Expand Down Expand Up @@ -9331,14 +9331,14 @@ function wrapFiber(fiber) {
}
var internals$jscomp$inline_1216 = {
bundleType: 0,
version: "19.0.0-native-fb-246d7bfe-20240826",
version: "19.0.0-native-fb-8d68da3f-20240903",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: function (mockNode) {
mockNode = nodeToInstanceMap.get(mockNode);
return void 0 !== mockNode ? mockNode.internalInstanceHandle : null;
},
reconcilerVersion: "19.0.0-native-fb-246d7bfe-20240826"
reconcilerVersion: "19.0.0-native-fb-8d68da3f-20240903"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1217 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -9474,4 +9474,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.0.0-native-fb-246d7bfe-20240826";
exports.version = "19.0.0-native-fb-8d68da3f-20240903";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<1730b3d88bae08be3715d2c99dbe4f36>>
* @generated SignedSource<<e248d99b7723de8d3af2a0d7fe19e52e>>
*/

"use strict";
Expand Down Expand Up @@ -9944,14 +9944,14 @@ function wrapFiber(fiber) {
}
var internals$jscomp$inline_1117 = {
bundleType: 0,
version: "19.0.0-native-fb-246d7bfe-20240826",
version: "19.0.0-native-fb-8d68da3f-20240903",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: function (mockNode) {
mockNode = nodeToInstanceMap.get(mockNode);
return void 0 !== mockNode ? mockNode.internalInstanceHandle : null;
},
reconcilerVersion: "19.0.0-native-fb-246d7bfe-20240826",
reconcilerVersion: "19.0.0-native-fb-8d68da3f-20240903",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$149 = 0;
Expand Down Expand Up @@ -10102,4 +10102,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.0.0-native-fb-246d7bfe-20240826";
exports.version = "19.0.0-native-fb-8d68da3f-20240903";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<896f79c85e8c2785f38cee89b95a332f>>
* @generated SignedSource<<3086926418188819cb264b2b4ce337d7>>
*/

"use strict";
Expand Down Expand Up @@ -1705,7 +1705,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.0.0-native-fb-246d7bfe-20240826";
exports.version = "19.0.0-native-fb-8d68da3f-20240903";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<fc1f4804ec761bcebe4c15d74709e0e6>>
* @generated SignedSource<<67e2739cc6ec149e186940fa71fedf5a>>
*/

"use strict";
Expand Down Expand Up @@ -580,4 +580,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-native-fb-246d7bfe-20240826";
exports.version = "19.0.0-native-fb-8d68da3f-20240903";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<695d3ab4be692d0760b33e3253e66289>>
* @generated SignedSource<<00f72c0d892fa33507b893f4a9760683>>
*/

"use strict";
Expand Down Expand Up @@ -584,7 +584,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-native-fb-246d7bfe-20240826";
exports.version = "19.0.0-native-fb-8d68da3f-20240903";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
246d7bfeb0c90ecccd9531929b60a79d628a4c78
8d68da3f7396064614f34b84881fe8833b6039ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<554f420a6fa3f25ed0f068fc6a103bef>>
* @generated SignedSource<<9ef28de841583eb0dc8a86a45dee3b60>>
*/

"use strict";
Expand Down Expand Up @@ -4571,6 +4571,14 @@ __DEV__ &&
}
function finishRenderingHooks(current, workInProgress) {
workInProgress._debugHookTypes = hookTypesDev;
null === workInProgress.dependencies
? null !== thenableState &&
(workInProgress.dependencies = {
lanes: 0,
firstContext: null,
_debugThenableState: thenableState
})
: (workInProgress.dependencies._debugThenableState = thenableState);
ReactSharedInternals.H = ContextOnlyDispatcher;
var didRenderTooFewHooks =
null !== currentHook && null !== currentHook.next;
Expand Down Expand Up @@ -8952,7 +8960,11 @@ __DEV__ &&
"Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()."
);
lastContextDependency = context;
consumer.dependencies = { lanes: 0, firstContext: context };
consumer.dependencies = {
lanes: 0,
firstContext: context,
_debugThenableState: null
};
enableLazyContextPropagation && (consumer.flags |= 524288);
} else lastContextDependency = lastContextDependency.next = context;
return value;
Expand Down Expand Up @@ -13464,7 +13476,8 @@ __DEV__ &&
? null
: {
lanes: pendingProps.lanes,
firstContext: pendingProps.firstContext
firstContext: pendingProps.firstContext,
_debugThenableState: pendingProps._debugThenableState
};
workInProgress.sibling = current.sibling;
workInProgress.index = current.index;
Expand Down Expand Up @@ -13517,7 +13530,8 @@ __DEV__ &&
? null
: {
lanes: renderLanes.lanes,
firstContext: renderLanes.firstContext
firstContext: renderLanes.firstContext,
_debugThenableState: renderLanes._debugThenableState
}),
(workInProgress.selfBaseDuration = current.selfBaseDuration),
(workInProgress.treeBaseDuration = current.treeBaseDuration));
Expand Down Expand Up @@ -16952,11 +16966,11 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.0.0-native-fb-246d7bfe-20240826",
version: "19.0.0-native-fb-8d68da3f-20240903",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-246d7bfe-20240826"
reconcilerVersion: "19.0.0-native-fb-8d68da3f-20240903"
};
null !== extraDevToolsConfig &&
(internals.rendererConfig = extraDevToolsConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<29f175ffe3a5d88a87ee965eaba00742>>
* @generated SignedSource<<acaa31fb9763a1810659aacab7dd2a6f>>
*/

"use strict";
Expand Down Expand Up @@ -10852,11 +10852,11 @@ batchedUpdatesImpl = function (fn, a) {
var roots = new Map(),
internals$jscomp$inline_1151 = {
bundleType: 0,
version: "19.0.0-native-fb-246d7bfe-20240826",
version: "19.0.0-native-fb-8d68da3f-20240903",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-246d7bfe-20240826"
reconcilerVersion: "19.0.0-native-fb-8d68da3f-20240903"
};
null !== extraDevToolsConfig &&
(internals$jscomp$inline_1151.rendererConfig = extraDevToolsConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9eaa9c4ff858b3df438918ddfcf7f694>>
* @generated SignedSource<<014d80b875dc73d152ab691019204f09>>
*/

"use strict";
Expand Down Expand Up @@ -11555,11 +11555,11 @@ batchedUpdatesImpl = function (fn, a) {
var roots = new Map(),
internals$jscomp$inline_1233 = {
bundleType: 0,
version: "19.0.0-native-fb-246d7bfe-20240826",
version: "19.0.0-native-fb-8d68da3f-20240903",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-246d7bfe-20240826"
reconcilerVersion: "19.0.0-native-fb-8d68da3f-20240903"
};
null !== extraDevToolsConfig &&
(internals$jscomp$inline_1233.rendererConfig = extraDevToolsConfig);
Expand Down
Loading

0 comments on commit 18e907e

Please sign in to comment.