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 commit d9e00f7.
  • Loading branch information
sebmarkbage committed Sep 22, 2023
1 parent 04fa1ae commit 59e0111
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23998,7 +23998,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-canary-f9d75e32b-20230922";
var ReactVersion = "18.3.0-canary-d9e00f795-20230922";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8620,7 +8620,7 @@ var devToolsConfig$jscomp$inline_1028 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-f9d75e32b-20230922",
version: "18.3.0-canary-d9e00f795-20230922",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1227 = {
Expand Down Expand Up @@ -8651,7 +8651,7 @@ var internals$jscomp$inline_1227 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-f9d75e32b-20230922"
reconcilerVersion: "18.3.0-canary-d9e00f795-20230922"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1228 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9046,7 +9046,7 @@ var devToolsConfig$jscomp$inline_1070 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-f9d75e32b-20230922",
version: "18.3.0-canary-d9e00f795-20230922",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1268 = {
Expand Down Expand Up @@ -9077,7 +9077,7 @@ var internals$jscomp$inline_1268 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-f9d75e32b-20230922"
reconcilerVersion: "18.3.0-canary-d9e00f795-20230922"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1269 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-canary-f9d75e32b-20230922";
var ReactVersion = "18.3.0-canary-d9e00f795-20230922";

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,4 +616,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-f9d75e32b-20230922";
exports.version = "18.3.0-canary-d9e00f795-20230922";
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-f9d75e32b-20230922";
exports.version = "18.3.0-canary-d9e00f795-20230922";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f9d75e32ba85b3c6a2a5d20fa27ba7e23d5529b2
d9e00f795b77676fb14f2a3c6f421f48f73bec2a

0 comments on commit 59e0111

Please sign in to comment.