Skip to content

Commit

Permalink
Revert "fix: Invoke cancel, only if the stream is not closed (#55684)" (
Browse files Browse the repository at this point in the history
  • Loading branch information
ztanner committed Sep 21, 2023
1 parent ea01649 commit ff7e4f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/next/src/server/pipe-readable.ts
Expand Up @@ -58,7 +58,7 @@ export async function pipeReadable(
// will also ensure the read promise rejects and frees our resources.
if (!readerDone) {
readerDone = true
if (!reader.closed) reader.cancel().catch(() => {})
reader.cancel().catch(() => {})
}
}
writable.on('close', onClose)
Expand Down Expand Up @@ -88,7 +88,7 @@ export async function pipeReadable(
// If we broke out of the loop because of a client disconnect, and the
// close event hasn't yet fired, we can early cancel.
if (!readerDone) {
if (!reader.closed) reader.cancel().catch(() => {})
reader.cancel().catch(() => {})
}

// If the client hasn't disconnected yet, end the writable so that the
Expand Down

0 comments on commit ff7e4f4

Please sign in to comment.