From 83b9e0144bdbfc155c7fa44972f14ef135a751ab Mon Sep 17 00:00:00 2001 From: sebmarkbage Date: Mon, 23 Oct 2023 19:59:15 +0000 Subject: [PATCH] [Fizz] Postponing in the shell (#27569) When we postpone a prerender in the shell, we should just leave an empty prelude and resume from the root. While preserving any options passed in. Since we haven't flushed anything we can't assume we've already emitted html/body tags or any resources tracked in the resumable state. This introduces a resetResumableState function to reset anything we didn't flush. This is a bit hacky. Ideally, we probably shouldn't have tracked it as already happened until it flushed or something like that. Basically, it's like restarting the prerender with the same options and then immediately aborting. When we add the preload headers, we'd track those as preload() being emitted after the reset and so they get readded to the resumable state in that case. DiffTrain build for [05fbd1aab036ecbd14469d6376024439bc931f68](https://github.com/facebook/react/commit/05fbd1aab036ecbd14469d6376024439bc931f68) --- compiled/facebook-www/REVISION | 2 +- compiled/facebook-www/ReactART-dev.modern.js | 2 +- compiled/facebook-www/ReactART-prod.modern.js | 4 ++-- compiled/facebook-www/ReactDOMServer-dev.classic.js | 9 ++++++--- compiled/facebook-www/ReactDOMServer-dev.modern.js | 9 ++++++--- compiled/facebook-www/ReactDOMServer-prod.classic.js | 4 ++-- compiled/facebook-www/ReactDOMServer-prod.modern.js | 4 ++-- .../facebook-www/ReactDOMServerStreaming-dev.modern.js | 7 +++++-- .../facebook-www/ReactDOMServerStreaming-prod.modern.js | 2 +- 9 files changed, 26 insertions(+), 17 deletions(-) diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index 6630afd631..c4f8883032 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -779d59374e8e852ce00728d895156a7574e1b456 +05fbd1aab036ecbd14469d6376024439bc931f68 diff --git a/compiled/facebook-www/ReactART-dev.modern.js b/compiled/facebook-www/ReactART-dev.modern.js index 44c41ab8bb..07710edcdf 100644 --- a/compiled/facebook-www/ReactART-dev.modern.js +++ b/compiled/facebook-www/ReactART-dev.modern.js @@ -69,7 +69,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = "18.3.0-www-modern-0b462672"; +var ReactVersion = "18.3.0-www-modern-f0ea8864"; var LegacyRoot = 0; var ConcurrentRoot = 1; diff --git a/compiled/facebook-www/ReactART-prod.modern.js b/compiled/facebook-www/ReactART-prod.modern.js index 9645e3f4e0..20cf956f7f 100644 --- a/compiled/facebook-www/ReactART-prod.modern.js +++ b/compiled/facebook-www/ReactART-prod.modern.js @@ -9850,7 +9850,7 @@ var slice = Array.prototype.slice, return null; }, bundleType: 0, - version: "18.3.0-www-modern-5b0eeab3", + version: "18.3.0-www-modern-4b9b2c3c", rendererPackageName: "react-art" }; var internals$jscomp$inline_1302 = { @@ -9881,7 +9881,7 @@ var internals$jscomp$inline_1302 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-5b0eeab3" + reconcilerVersion: "18.3.0-www-modern-4b9b2c3c" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1303 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled/facebook-www/ReactDOMServer-dev.classic.js b/compiled/facebook-www/ReactDOMServer-dev.classic.js index 16d59095fb..10f93543ec 100644 --- a/compiled/facebook-www/ReactDOMServer-dev.classic.js +++ b/compiled/facebook-www/ReactDOMServer-dev.classic.js @@ -19,7 +19,7 @@ if (__DEV__) { var React = require("react"); var ReactDOM = require("react-dom"); -var ReactVersion = "18.3.0-www-classic-3ac6c75e"; +var ReactVersion = "18.3.0-www-classic-38d7e1a0"; // This refers to a WWW module. var warningWWW = require("warning"); @@ -2318,7 +2318,7 @@ function createResumableState(identifierPrefix, externalRuntimeConfig) { moduleUnknownResources: {}, moduleScriptResources: {} }; -} // Constants for the insertion mode we're currently writing in. We don't encode all HTML5 insertion +} // modes. We only include the variants as they matter for the sake of our purposes. // We don't actually provide the namespace therefore we use constants instead of the string. @@ -13094,7 +13094,10 @@ function flushCompletedQueues(request, destination) { var completedRootSegment = request.completedRootSegment; if (completedRootSegment !== null) { - if (request.pendingRootTasks === 0) { + if (completedRootSegment.status === POSTPONED) { + // We postponed the root, so we write nothing. + return; + } else if (request.pendingRootTasks === 0) { if (enableFloat) { writePreamble( destination, diff --git a/compiled/facebook-www/ReactDOMServer-dev.modern.js b/compiled/facebook-www/ReactDOMServer-dev.modern.js index 435c81d638..dbee83081f 100644 --- a/compiled/facebook-www/ReactDOMServer-dev.modern.js +++ b/compiled/facebook-www/ReactDOMServer-dev.modern.js @@ -19,7 +19,7 @@ if (__DEV__) { var React = require("react"); var ReactDOM = require("react-dom"); -var ReactVersion = "18.3.0-www-modern-0b462672"; +var ReactVersion = "18.3.0-www-modern-f0ea8864"; // This refers to a WWW module. var warningWWW = require("warning"); @@ -2318,7 +2318,7 @@ function createResumableState(identifierPrefix, externalRuntimeConfig) { moduleUnknownResources: {}, moduleScriptResources: {} }; -} // Constants for the insertion mode we're currently writing in. We don't encode all HTML5 insertion +} // modes. We only include the variants as they matter for the sake of our purposes. // We don't actually provide the namespace therefore we use constants instead of the string. @@ -12842,7 +12842,10 @@ function flushCompletedQueues(request, destination) { var completedRootSegment = request.completedRootSegment; if (completedRootSegment !== null) { - if (request.pendingRootTasks === 0) { + if (completedRootSegment.status === POSTPONED) { + // We postponed the root, so we write nothing. + return; + } else if (request.pendingRootTasks === 0) { if (enableFloat) { writePreamble( destination, diff --git a/compiled/facebook-www/ReactDOMServer-prod.classic.js b/compiled/facebook-www/ReactDOMServer-prod.classic.js index 93795d4a5a..bf27ac29ee 100644 --- a/compiled/facebook-www/ReactDOMServer-prod.classic.js +++ b/compiled/facebook-www/ReactDOMServer-prod.classic.js @@ -4655,7 +4655,7 @@ function flushCompletedQueues(request, destination) { var i, completedRootSegment = request.completedRootSegment; if (null !== completedRootSegment) - if (0 === request.pendingRootTasks) { + if (5 !== completedRootSegment.status && 0 === request.pendingRootTasks) { var renderState = request.renderState; if ( (0 !== request.allPendingTasks || @@ -5054,4 +5054,4 @@ exports.renderToString = function (children, options) { 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server' ); }; -exports.version = "18.3.0-www-classic-5696169c"; +exports.version = "18.3.0-www-classic-38c26c34"; diff --git a/compiled/facebook-www/ReactDOMServer-prod.modern.js b/compiled/facebook-www/ReactDOMServer-prod.modern.js index 19abaac444..0ca4843a93 100644 --- a/compiled/facebook-www/ReactDOMServer-prod.modern.js +++ b/compiled/facebook-www/ReactDOMServer-prod.modern.js @@ -4590,7 +4590,7 @@ function flushCompletedQueues(request, destination) { var i, completedRootSegment = request.completedRootSegment; if (null !== completedRootSegment) - if (0 === request.pendingRootTasks) { + if (5 !== completedRootSegment.status && 0 === request.pendingRootTasks) { var renderState = request.renderState; if ( (0 !== request.allPendingTasks || @@ -4989,4 +4989,4 @@ exports.renderToString = function (children, options) { 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server' ); }; -exports.version = "18.3.0-www-modern-5b0eeab3"; +exports.version = "18.3.0-www-modern-4b9b2c3c"; diff --git a/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js b/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js index ea2d72912e..3c9c92adae 100644 --- a/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js +++ b/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js @@ -2315,7 +2315,7 @@ function createResumableState(identifierPrefix, externalRuntimeConfig) { moduleUnknownResources: {}, moduleScriptResources: {} }; -} // Constants for the insertion mode we're currently writing in. We don't encode all HTML5 insertion +} // modes. We only include the variants as they matter for the sake of our purposes. // We don't actually provide the namespace therefore we use constants instead of the string. @@ -12723,7 +12723,10 @@ function flushCompletedQueues(request, destination) { var completedRootSegment = request.completedRootSegment; if (completedRootSegment !== null) { - if (request.pendingRootTasks === 0) { + if (completedRootSegment.status === POSTPONED) { + // We postponed the root, so we write nothing. + return; + } else if (request.pendingRootTasks === 0) { if (enableFloat) { writePreamble( destination, diff --git a/compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js b/compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js index c30ac1cbb3..e6b53771b1 100644 --- a/compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js +++ b/compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js @@ -4370,7 +4370,7 @@ function flushCompletedQueues(request, destination) { var i, completedRootSegment = request.completedRootSegment; if (null !== completedRootSegment) - if (0 === request.pendingRootTasks) { + if (5 !== completedRootSegment.status && 0 === request.pendingRootTasks) { var renderState = request.renderState; if ( (0 !== request.allPendingTasks ||