From 7d8a8d9c3f071a7fc9de8f918848051ced0a3fb4 Mon Sep 17 00:00:00 2001 From: gnoff Date: Fri, 8 Dec 2023 19:10:45 +0000 Subject: [PATCH] [Flight] Support postponing through a serialized promise (#27818) Postponing in a promise that is being serialized to the client from the server should be possible however prior to this change Flight treated this case like an error rather than a postpone. This fix adds support for postponing in this position and adds a test asserting you can successfully prerender the root if you unwrap this promise inside a suspense boundary. DiffTrain build for [5bcade5fcf5610e82e7cda05cc6de574bdace0c7](https://github.com/facebook/react/commit/5bcade5fcf5610e82e7cda05cc6de574bdace0c7) --- compiled/facebook-www/REVISION | 2 +- compiled/facebook-www/ReactDOMTesting-prod.modern.js | 6 +++--- .../facebook-www/ReactFlightDOMServer-dev.modern.js | 12 ++++++++---- .../facebook-www/ReactFlightDOMServer-prod.modern.js | 2 +- .../facebook-www/ReactTestRenderer-dev.modern.js | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index ecf6d3df69629..075d96376224a 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -8ff2c236a233a78c18d6f524dd74baec9153fd37 +5bcade5fcf5610e82e7cda05cc6de574bdace0c7 diff --git a/compiled/facebook-www/ReactDOMTesting-prod.modern.js b/compiled/facebook-www/ReactDOMTesting-prod.modern.js index ba5bcbdc091cb..424e93d6ff72a 100644 --- a/compiled/facebook-www/ReactDOMTesting-prod.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-prod.modern.js @@ -16449,7 +16449,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1784 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-ade0aaf2", + version: "18.3.0-www-modern-faf29095", rendererPackageName: "react-dom" }; var internals$jscomp$inline_2140 = { @@ -16480,7 +16480,7 @@ var internals$jscomp$inline_2140 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-ade0aaf2" + reconcilerVersion: "18.3.0-www-modern-faf29095" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2141 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -16896,4 +16896,4 @@ exports.useFormState = function () { exports.useFormStatus = function () { throw Error(formatProdErrorMessage(248)); }; -exports.version = "18.3.0-www-modern-ade0aaf2"; +exports.version = "18.3.0-www-modern-faf29095"; diff --git a/compiled/facebook-www/ReactFlightDOMServer-dev.modern.js b/compiled/facebook-www/ReactFlightDOMServer-dev.modern.js index 25bc6b9b16561..5b03c7a4e2eda 100644 --- a/compiled/facebook-www/ReactFlightDOMServer-dev.modern.js +++ b/compiled/facebook-www/ReactFlightDOMServer-dev.modern.js @@ -1408,11 +1408,15 @@ if (__DEV__) { pingTask(request, newTask); }, function (reason) { - newTask.status = ERRORED; - request.abortableTasks.delete(newTask); // TODO: We should ideally do this inside performWork so it's scheduled + { + newTask.status = ERRORED; + + var _digest = logRecoverableError(request, reason); + + emitErrorChunk(request, newTask.id, _digest, reason); + } - var digest = logRecoverableError(request, reason); - emitErrorChunk(request, newTask.id, digest, reason); + request.abortableTasks.delete(newTask); if (request.destination !== null) { flushCompletedChunks(request, request.destination); diff --git a/compiled/facebook-www/ReactFlightDOMServer-prod.modern.js b/compiled/facebook-www/ReactFlightDOMServer-prod.modern.js index a968acdc54e8d..ea107940be829 100644 --- a/compiled/facebook-www/ReactFlightDOMServer-prod.modern.js +++ b/compiled/facebook-www/ReactFlightDOMServer-prod.modern.js @@ -585,9 +585,9 @@ function serializeThenable(request, thenable) { }, function (reason) { newTask.status = 4; - request.abortableTasks.delete(newTask); reason = logRecoverableError(request, reason); emitErrorChunk(request, newTask.id, reason); + request.abortableTasks.delete(newTask); null !== request.destination && flushCompletedChunks(request, request.destination); } diff --git a/compiled/facebook-www/ReactTestRenderer-dev.modern.js b/compiled/facebook-www/ReactTestRenderer-dev.modern.js index 16b5b84ccf571..cc6903f028a4e 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.modern.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.modern.js @@ -25929,7 +25929,7 @@ if (__DEV__) { return root; } - var ReactVersion = "18.3.0-www-modern-a95f6e9d"; + var ReactVersion = "18.3.0-www-modern-7278ec4c"; // Might add PROFILE later.