Skip to content

Commit

Permalink
[Flight] Move pendingChunks ref count increment into createTask (#28260)
Browse files Browse the repository at this point in the history
Every time we create a task we need to wait for it so we increase a ref
count. We can do this in `createTask`. This is in line with what Fizz
does too.

They differ in that Flight counts when they're actually flushed where as
Fizz decrements them when they complete.

Flight should probably count them when they complete so it's possible to
wait for the end before flushing for buffering purposes.

DiffTrain build for [0d11563](0d11563)
  • Loading branch information
sebmarkbage committed Feb 6, 2024
1 parent aa5199b commit e46929f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
66924457594bc28eb2f3f39c7c61d54b931c188e
0d11563b4a96e0f4f2361cdf7375b12375688163
6 changes: 3 additions & 3 deletions compiled/facebook-www/ReactDOMTesting-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -17067,7 +17067,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1787 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-modern-280d1df6",
version: "18.3.0-www-modern-941395b7",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2160 = {
Expand Down Expand Up @@ -17098,7 +17098,7 @@ var internals$jscomp$inline_2160 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-280d1df6"
reconcilerVersion: "18.3.0-www-modern-941395b7"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2161 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -17526,4 +17526,4 @@ exports.useFormStatus = function () {
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
throw Error(formatProdErrorMessage(248));
};
exports.version = "18.3.0-www-modern-280d1df6";
exports.version = "18.3.0-www-modern-941395b7";
5 changes: 1 addition & 4 deletions compiled/facebook-www/ReactFlightDOMServer-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,6 @@ if (__DEV__) {
onPostpone:
onPostpone === undefined ? defaultPostponeHandler : onPostpone
};
request.pendingChunks++;
var rootTask = createTask(request, model, null, false, abortSet);
pingedTasks.push(rootTask);
return request;
Expand All @@ -1159,7 +1158,6 @@ if (__DEV__) {
}

function serializeThenable(request, task, thenable) {
request.pendingChunks++;
var newTask = createTask(
request,
null,
Expand Down Expand Up @@ -1550,6 +1548,7 @@ if (__DEV__) {
}

function createTask(request, model, keyPath, implicitSlot, abortSet) {
request.pendingChunks++;
var id = request.nextChunkId++;

if (typeof model === "object" && model !== null) {
Expand Down Expand Up @@ -1733,7 +1732,6 @@ if (__DEV__) {
}

function outlineModel(request, value) {
request.pendingChunks++;
var newTask = createTask(
request,
value,
Expand Down Expand Up @@ -1856,7 +1854,6 @@ if (__DEV__) {
// $FlowFixMe[method-unbinding]
if (typeof x.then === "function") {
// Something suspended, we'll need to create a new task and resolve it later.
request.pendingChunks++;
var newTask = createTask(
request,
task.model,
Expand Down
5 changes: 1 addition & 4 deletions compiled/facebook-www/ReactFlightDOMServer-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ function defaultErrorHandler(error) {
function defaultPostponeHandler() {}
var currentRequest = null;
function serializeThenable(request, task, thenable) {
request.pendingChunks++;
var newTask = createTask(
request,
null,
Expand Down Expand Up @@ -649,6 +648,7 @@ function pingTask(request, task) {
performWork(request));
}
function createTask(request, model, keyPath, implicitSlot, abortSet) {
request.pendingChunks++;
var id = request.nextChunkId++;
"object" !== typeof model ||
null === model ||
Expand Down Expand Up @@ -691,7 +691,6 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
null !== parentPropertyName &&
"function" === typeof parentPropertyName.then)
) {
request.pendingChunks++;
JSCompiler_inline_result = createTask(
request,
task.model,
Expand Down Expand Up @@ -773,7 +772,6 @@ function serializeClientReference(
}
}
function outlineModel(request, value) {
request.pendingChunks++;
value = createTask(request, value, null, !1, request.abortableTasks);
retryTask(request, value);
return value.id;
Expand Down Expand Up @@ -1122,7 +1120,6 @@ exports.renderToDestination = function (destination, model, options) {
onError: void 0 === onError ? defaultErrorHandler : onError,
onPostpone: defaultPostponeHandler
};
onError.pendingChunks++;
model = createTask(onError, model, null, !1, abortSet);
options.push(model);
onError.flushScheduled = null !== onError.destination;
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/ReactTestRenderer-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -26083,7 +26083,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-www-modern-895f9e13";
var ReactVersion = "18.3.0-www-modern-6f034660";

// Might add PROFILE later.

Expand Down

0 comments on commit e46929f

Please sign in to comment.