diff options
author | Andreu Botella <abb@randomunok.com> | 2021-07-02 11:34:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-02 11:34:12 +0200 |
commit | 4bc8fe71db89d3c430bc615815a15b7ee04476c7 (patch) | |
tree | 53afe3c0ecac4d735619e0d2cd5e107acf0623ef | |
parent | 513f921219d32fe5deea264f6604b54b24d81d8f (diff) |
fix(fetch): a consumed body with a non-stream source should result in a disturbed stream (#11217)
-rw-r--r-- | extensions/fetch/22_body.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/extensions/fetch/22_body.js b/extensions/fetch/22_body.js index 9b5bf8eff..c683ca14f 100644 --- a/extensions/fetch/22_body.js +++ b/extensions/fetch/22_body.js @@ -41,14 +41,16 @@ get stream() { if (!(this.streamOrStatic instanceof ReadableStream)) { const { body, consumed } = this.streamOrStatic; - this.streamOrStatic = new ReadableStream({ - start(controller) { - controller.enqueue(body); - controller.close(); - }, - }); if (consumed) { - this.streamOrStatic.cancel(); + this.streamOrStatic = new ReadableStream(); + this.streamOrStatic.getReader(); + } else { + this.streamOrStatic = new ReadableStream({ + start(controller) { + controller.enqueue(body); + controller.close(); + }, + }); } } return this.streamOrStatic; |