diff options
-rw-r--r-- | ext/web/06_streams.js | 2 | ||||
-rw-r--r-- | tests/unit/command_test.ts | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 1dbf769b2..a4f2275c5 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -1054,7 +1054,7 @@ async function readableStreamCollectIntoUint8Array(stream) { getReadableStreamResourceBackingUnrefable(stream); const reader = acquireReadableStreamDefaultReader(stream); - if (resourceBacking) { + if (resourceBacking && !isReadableStreamDisturbed(stream)) { // fast path, read whole body in a single op call try { readableStreamDisturb(stream); diff --git a/tests/unit/command_test.ts b/tests/unit/command_test.ts index 523d20cf3..51bbdd860 100644 --- a/tests/unit/command_test.ts +++ b/tests/unit/command_test.ts @@ -1043,3 +1043,24 @@ Deno.test( } }, ); + +Deno.test(async function outputWhenManuallyConsumingStreams() { + const command = new Deno.Command(Deno.execPath(), { + args: ["eval", "console.log('hello world')"], + stdout: "piped", + stderr: "piped", + }); + const child = command.spawn(); + for await (const _ of child.stdout) { + // consume stdout + } + for await (const _ of child.stderr) { + // consume stderr + } + const status = await child.output(); + assertEquals(status.success, true); + assertEquals(status.code, 0); + assertEquals(status.signal, null); + assertEquals(status.stdout, new Uint8Array()); + assertEquals(status.stderr, new Uint8Array()); +}); |