From 8178f758bc249f12fb82fce15a8f63be1b907ddb Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Sat, 27 Apr 2024 20:25:18 +0900 Subject: fix(ext/node): support process.stdin.unref() (#22865) This PR adds private `[REF]()` and `[UNREF]()` methods to Stdin class, and call them from Node.js polyfill layer (`TTY` class). This enables `process.stdin.unref()` and `process.stdin.ref()` for the case when stdin is terminal. closes #21796 --- ext/node/polyfills/tty.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'ext/node') diff --git a/ext/node/polyfills/tty.js b/ext/node/polyfills/tty.js index c44f7e946..3a84a1f94 100644 --- a/ext/node/polyfills/tty.js +++ b/ext/node/polyfills/tty.js @@ -9,7 +9,10 @@ const { } = core; import { ERR_INVALID_FD } from "ext:deno_node/internal/errors.ts"; -import { LibuvStreamWrap } from "ext:deno_node/internal_binding/stream_wrap.ts"; +import { + kStreamBaseField, + LibuvStreamWrap, +} from "ext:deno_node/internal_binding/stream_wrap.ts"; import { providerType } from "ext:deno_node/internal_binding/async_wrap.ts"; import { Socket } from "node:net"; import { setReadStream } from "ext:deno_node/_process/streams.mjs"; @@ -36,6 +39,14 @@ class TTY extends LibuvStreamWrap { constructor(handle) { super(providerType.TTYWRAP, handle); } + + ref() { + this[kStreamBaseField][io.REF](); + } + + unref() { + this[kStreamBaseField][io.UNREF](); + } } export class ReadStream extends Socket { -- cgit v1.2.3