Skip to content

Commit

Permalink
Stop flowing and then abort if a stream is cancelled (#27405)
Browse files Browse the repository at this point in the history
We currently abort a stream either it's explicitly told to abort (e.g.
by an abortsignal). In this case we still finish writing what we have as
well as instructions for the client about what happened so it can
trigger fallback cases and log appropriately.

We also abort a request if the stream itself cancels. E.g. if you can't
write anymore. In this case we should not write anything to the outgoing
stream since it's supposed to be closed already now. However, we should
still abort the request so that more work isn't performed and so that we
can log the reason for it to the onError callback.

We should also not do any work after aborting.

There we need to stop the "flow" of bytes - so I call stopFlowing in the
cancel case before aborting.

The tests were testing this case but we had changed the implementation
to only start flowing at initial read (pull) instead of start like we
used to. As a result, it was no longer covering this case. We have to
call reader.read() in the tests to start the flow so that we need to
cancel it.

We also were missing a final assertion on the error logs and since we
were tracking them explicitly the extra error was silenced.

DiffTrain build for [d9e00f7](d9e00f7)
  • Loading branch information
sebmarkbage committed Sep 22, 2023
1 parent 109381d commit 26f3e58
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
68ac6dbcf8d58a67e94e9061395dd96a52d92377
d9e00f795b77676fb14f2a3c6f421f48f73bec2a
4 changes: 2 additions & 2 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-24cad190";
var ReactVersion = "18.3.0-www-classic-8314963c";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -13120,7 +13120,7 @@ function startFlowing(request, destination) {
logRecoverableError(request, error);
fatalError(request, error);
}
} // This is called to early terminate a request. It puts all pending boundaries in client rendered state.
}

function abort(request, reason) {
try {
Expand Down
4 changes: 2 additions & 2 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-0d8cdce2";
var ReactVersion = "18.3.0-www-modern-4ddb3d62";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -12868,7 +12868,7 @@ function startFlowing(request, destination) {
logRecoverableError(request, error);
fatalError(request, error);
}
} // This is called to early terminate a request. It puts all pending boundaries in client rendered state.
}

function abort(request, reason) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12738,7 +12738,7 @@ function startFlowing(request, destination) {
logRecoverableError(request, error);
fatalError(request, error);
}
} // This is called to early terminate a request. It puts all pending boundaries in client rendered state.
}

function abort(request, reason) {
try {
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 @@ -24360,7 +24360,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-modern-959bcb71";
var ReactVersion = "18.3.0-www-modern-9ffb854c";

// Might add PROFILE later.

Expand Down

0 comments on commit 26f3e58

Please sign in to comment.