Skip to content

Commit

Permalink
[Fizz] Support aborting with Postpone (#28183)
Browse files Browse the repository at this point in the history
Semantically if you make your reason for aborting a Postpone instance
the render should not hit the error pathways but should instead follow
the postpone pathways. It's awkward today to actually get your hands on
a Postpone instance because you have to catch the throw from postpone
and then pass that into `abort()` or `AbortController.abort()`
(depending on the renderer API you are using)

This change makes it so that in most circumstances if you abort with a
postpone the `onPostpone` handler will be called and the Suspense
boundaries still pending will be put into client render mode with the
appropriate postpone digest to avoid trigger recoverable error pathways
on the client.

Similar to postponing in the shell during a resume or render however if
you abort before the shell is complete in a resume or render we will
fatally error. The fatal error is contextualized by React to avoid
passing the postpone object itself to the `onError` and related options.

DiffTrain build for [1219d57](1219d57)
  • Loading branch information
gnoff committed Feb 1, 2024
1 parent 5f66358 commit 72343e6
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 16 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f3ce87ab650f07774e1df9bc3f8033e023973d10
1219d57fc9fcbf44c873c0b10e5acbd31f613c15
22 changes: 17 additions & 5 deletions compiled/facebook-www/ReactDOMServer-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "18.3.0-www-classic-34681660";
var ReactVersion = "18.3.0-www-classic-71ea3c5d";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -13273,8 +13273,11 @@ if (__DEV__) {
if (replay === null) {
// We didn't complete the root so we have nothing to show. We can close
// the request;
logRecoverableError(request, error, errorInfo);
fatalError(request, error);
{
logRecoverableError(request, error, errorInfo);
fatalError(request, error);
}

return;
} else {
// If the shell aborts during a replay, that's not a fatal error. Instead
Expand All @@ -13283,7 +13286,12 @@ if (__DEV__) {
replay.pendingTasks--;

if (replay.pendingTasks === 0 && replay.nodes.length > 0) {
var errorDigest = logRecoverableError(request, error, errorInfo);
var errorDigest;

{
errorDigest = logRecoverableError(request, error, errorInfo);
}

abortRemainingReplayNodes(
request,
null,
Expand Down Expand Up @@ -13311,7 +13319,11 @@ if (__DEV__) {

var _errorInfo = getThrownInfo(request, task.componentStack);

var _errorDigest = logRecoverableError(request, error, _errorInfo);
var _errorDigest;

{
_errorDigest = logRecoverableError(request, error, _errorInfo);
}

var errorMessage = error;

Expand Down
22 changes: 17 additions & 5 deletions compiled/facebook-www/ReactDOMServer-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "18.3.0-www-modern-4d7ad08b";
var ReactVersion = "18.3.0-www-modern-e061c5a2";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -13001,8 +13001,11 @@ if (__DEV__) {
if (replay === null) {
// We didn't complete the root so we have nothing to show. We can close
// the request;
logRecoverableError(request, error, errorInfo);
fatalError(request, error);
{
logRecoverableError(request, error, errorInfo);
fatalError(request, error);
}

return;
} else {
// If the shell aborts during a replay, that's not a fatal error. Instead
Expand All @@ -13011,7 +13014,12 @@ if (__DEV__) {
replay.pendingTasks--;

if (replay.pendingTasks === 0 && replay.nodes.length > 0) {
var errorDigest = logRecoverableError(request, error, errorInfo);
var errorDigest;

{
errorDigest = logRecoverableError(request, error, errorInfo);
}

abortRemainingReplayNodes(
request,
null,
Expand Down Expand Up @@ -13039,7 +13047,11 @@ if (__DEV__) {

var _errorInfo = getThrownInfo(request, task.componentStack);

var _errorDigest = logRecoverableError(request, error, _errorInfo);
var _errorDigest;

{
_errorDigest = logRecoverableError(request, error, _errorInfo);
}

var errorMessage = error;

Expand Down
20 changes: 16 additions & 4 deletions compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -12882,8 +12882,11 @@ if (__DEV__) {
if (replay === null) {
// We didn't complete the root so we have nothing to show. We can close
// the request;
logRecoverableError(request, error, errorInfo);
fatalError(request, error);
{
logRecoverableError(request, error, errorInfo);
fatalError(request, error);
}

return;
} else {
// If the shell aborts during a replay, that's not a fatal error. Instead
Expand All @@ -12892,7 +12895,12 @@ if (__DEV__) {
replay.pendingTasks--;

if (replay.pendingTasks === 0 && replay.nodes.length > 0) {
var errorDigest = logRecoverableError(request, error, errorInfo);
var errorDigest;

{
errorDigest = logRecoverableError(request, error, errorInfo);
}

abortRemainingReplayNodes(
request,
null,
Expand Down Expand Up @@ -12920,7 +12928,11 @@ if (__DEV__) {

var _errorInfo = getThrownInfo(request, task.componentStack);

var _errorDigest = logRecoverableError(request, error, _errorInfo);
var _errorDigest;

{
_errorDigest = logRecoverableError(request, error, _errorInfo);
}

var errorMessage = error;

Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/ReactServer-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,4 +474,4 @@ exports.useId = function () {
exports.useMemo = function (create, deps) {
return ReactCurrentDispatcher.current.useMemo(create, deps);
};
exports.version = "18.3.0-www-modern-4d7ad08b";
exports.version = "18.3.0-www-modern-e061c5a2";

0 comments on commit 72343e6

Please sign in to comment.