summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-11-20 05:27:18 -0800
committerGitHub <noreply@github.com>2023-11-20 18:57:18 +0530
commitc97a97240bb60d00f7a28ef327f444a9b6820f37 (patch)
treef9815c64216bcf359749a73127e35b1e57ea24e2
parent611e71cf3b053f350006cc55b6387603a894ca13 (diff)
fix(ext/node): handle closing process.stdin more than once (#21267)
Fixes https://github.com/denoland/deno/issues/21112 Aligns more towards what Node.js does. Closing stdin more than once is a nop.
-rw-r--r--cli/tests/unit_node/process_test.ts2
-rw-r--r--ext/io/12_io.js2
2 files changed, 3 insertions, 1 deletions
diff --git a/cli/tests/unit_node/process_test.ts b/cli/tests/unit_node/process_test.ts
index cd0dff0a4..a572f11b2 100644
--- a/cli/tests/unit_node/process_test.ts
+++ b/cli/tests/unit_node/process_test.ts
@@ -365,6 +365,8 @@ Deno.test({
name: "process.stdin readable with a TTY",
// TODO(PolarETech): Run this test even in non tty environment
ignore: !Deno.isatty(Deno.stdin.rid),
+ // stdin resource is present before the test starts.
+ sanitizeResources: false,
async fn() {
const promise = deferred();
const expected = ["foo", "bar", null, "end"];
diff --git a/ext/io/12_io.js b/ext/io/12_io.js
index 1bb8f9fba..e1d72ffb5 100644
--- a/ext/io/12_io.js
+++ b/ext/io/12_io.js
@@ -241,7 +241,7 @@ class Stdin {
}
close() {
- core.close(this.rid);
+ core.tryClose(this.rid);
}
get readable() {