summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2024-09-16 14:23:40 +0200
committerGitHub <noreply@github.com>2024-09-16 14:23:40 +0200
commit74069add3f400ad6b232ad18840206ab96b9fe80 (patch)
tree8823267812b6e4b683cc9f48431b866f9a276549 /tests/unit
parentf8547e2617a5bbef4931ac0df6e70db6b901927f (diff)
fix(runtime): don't error `child.output()` on consumed stream (#25657)
This fixes the fast path for `readableStreamCollectIntoUint8Array` to only trigger if the readable stream has not yet been disturbed - because otherwise we may not be able to close it if the read errors.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/command_test.ts21
1 files changed, 21 insertions, 0 deletions
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());
+});