mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
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.
This commit is contained in:
parent
f8547e2617
commit
74069add3f
2 changed files with 22 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue