From 809ff5e6c202d1e02d4eae9b797972dfb81e87b7 Mon Sep 17 00:00:00 2001 From: chloe caruso Date: Sun, 19 Jan 2025 00:29:50 -0800 Subject: [PATCH] test stdio closed --- src/js/builtins/ProcessObjectInternals.ts | 6 +++--- src/js/node/tty.ts | 4 ---- test/js/node/test/parallel/test-stdio-closed.js | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/js/builtins/ProcessObjectInternals.ts b/src/js/builtins/ProcessObjectInternals.ts index 75a227ee85..faaa9b2a76 100644 --- a/src/js/builtins/ProcessObjectInternals.ts +++ b/src/js/builtins/ProcessObjectInternals.ts @@ -29,7 +29,7 @@ export function getStdioWriteStream(fd) { let stream; if (tty.isatty(fd)) { - stream = new tty.WriteStream(fd); + stream = new tty.WriteStream(null, { fd }); // TODO: this is the wrong place for this property. // but the TTY is technically duplex // see test-fs-syncwritestream.js @@ -40,7 +40,7 @@ export function getStdioWriteStream(fd) { stream._type = "tty"; } else { const fs = require("node:fs"); - stream = new fs.WriteStream(fd, { autoClose: false, fd }); + stream = new fs.WriteStream(null, { autoClose: false, fd }); stream.readable = false; stream._type = "fs"; } @@ -125,7 +125,7 @@ export function getStdinStream(fd) { const tty = require("node:tty"); const ReadStream = tty.isatty(fd) ? tty.ReadStream : require("node:fs").ReadStream; - const stream = new ReadStream(fd); + const stream = new ReadStream(null, { fd }); const originalOn = stream.on; diff --git a/src/js/node/tty.ts b/src/js/node/tty.ts index 1daa2eaa39..ac05466827 100644 --- a/src/js/node/tty.ts +++ b/src/js/node/tty.ts @@ -10,10 +10,7 @@ function ReadStream(fd) { if (!(this instanceof ReadStream)) { return new ReadStream(fd); } - if (fd >> 0 !== fd || fd < 0) throw new RangeError("fd must be a positive integer"); - require("node:fs").ReadStream.$apply(this, ["", { fd }]); - this.isRaw = false; this.isTTY = true; } @@ -79,7 +76,6 @@ Object.defineProperty(ReadStream, "prototype", { function WriteStream(fd) { if (!(this instanceof WriteStream)) return new WriteStream(fd); - if (fd >> 0 !== fd || fd < 0) throw new RangeError("fd must be a positive integer"); const stream = require("node:fs").WriteStream.$call(this, "", { fd }); diff --git a/test/js/node/test/parallel/test-stdio-closed.js b/test/js/node/test/parallel/test-stdio-closed.js index cc9f1e86cc..45f6d0832f 100644 --- a/test/js/node/test/parallel/test-stdio-closed.js +++ b/test/js/node/test/parallel/test-stdio-closed.js @@ -20,6 +20,7 @@ if (common.isWindows) { proc.on('exit', common.mustCall(function(exitCode) { assert.strictEqual(exitCode, 0); })); + proc.stderr.pipe(process.stderr); return; }