From 300eeb343efa00d9572d3befa47ca88fb51c7ac6 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Thu, 25 Jan 2024 06:09:49 +1100 Subject: feat: deprecate `Deno.{stdin,stdout,stderr}.rid` (#22073) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For removal in Deno v2. There are two issues: 1. Any script being run causes the output of `warnOnDeprecatedApi()` to be printed, even when none of the `rid` properties are called. 2. `.rid` of these classes is used in multiple tests. I'm not sure how to account for that. I thought of having `STDIN_RID`, and friends, constants, whose values can be shared between the tests and the classes themselves. Should we go with that or do something else? --------- Co-authored-by: Bartek IwaƄczuk --- ext/node/polyfills/_process/streams.mjs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'ext/node/polyfills/_process/streams.mjs') diff --git a/ext/node/polyfills/_process/streams.mjs b/ext/node/polyfills/_process/streams.mjs index 166d099c8..09c53eb9a 100644 --- a/ext/node/polyfills/_process/streams.mjs +++ b/ext/node/polyfills/_process/streams.mjs @@ -37,7 +37,14 @@ export function createWritableStdioStream(writer, name) { } }, }); - stream.fd = writer?.rid ?? -1; + let fd = -1; + + if (writer instanceof io.Stdout) { + fd = io.STDOUT_RID; + } else if (writer instanceof io.Stderr) { + fd = io.STDERR_RID; + } + stream.fd = fd; stream.destroySoon = stream.destroy; stream._isStdio = true; stream.once("close", () => writer?.close()); @@ -117,7 +124,7 @@ export function setReadStream(s) { // https://github.com/nodejs/node/blob/v18.12.1/lib/internal/bootstrap/switches/is_main_thread.js#L189 /** Create process.stdin */ export const initStdin = () => { - const fd = io.stdin?.rid; + const fd = io.stdin ? io.STDIN_RID : undefined; let stdin; const stdinType = _guessStdinType(fd); @@ -172,7 +179,7 @@ export const initStdin = () => { } stdin.on("close", () => io.stdin?.close()); - stdin.fd = io.stdin?.rid ?? -1; + stdin.fd = io.stdin ? io.STDIN_RID : -1; Object.defineProperty(stdin, "isTTY", { enumerable: true, configurable: true, -- cgit v1.2.3