From 4db20c7eba810b64f166a75898abce20b17faf48 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Mon, 25 Nov 2024 20:19:01 +0530 Subject: [PATCH 1/8] fix(ext/node): unref pending reads in `readStop` --- ext/io/12_io.js | 2 ++ ext/node/polyfills/internal_binding/stream_wrap.ts | 6 ++++++ test.mjs | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 test.mjs diff --git a/ext/io/12_io.js b/ext/io/12_io.js index 3cdcb113ba750c..aca25cf082749d 100644 --- a/ext/io/12_io.js +++ b/ext/io/12_io.js @@ -170,6 +170,8 @@ class Stdin { if (this.#opPromise) { core.unrefOpPromise(this.#opPromise); } + // Reset the promise so that it can be re-ref'd. + this.#opPromise = undefined; } } diff --git a/ext/node/polyfills/internal_binding/stream_wrap.ts b/ext/node/polyfills/internal_binding/stream_wrap.ts index 7aea83d6f5899c..9938b9a85a0cb1 100644 --- a/ext/node/polyfills/internal_binding/stream_wrap.ts +++ b/ext/node/polyfills/internal_binding/stream_wrap.ts @@ -153,6 +153,12 @@ export class LibuvStreamWrap extends HandleWrap { readStop(): number { this.#reading = false; + // Unref any reads that are pending until this point. + if (this.unref) { + this.unref(); + this.ref(); + } + return 0; } diff --git a/test.mjs b/test.mjs new file mode 100644 index 00000000000000..8943852217d5c8 --- /dev/null +++ b/test.mjs @@ -0,0 +1,4 @@ +import { confirm } from "npm:@inquirer/prompts"; + +const answer = await confirm({ message: "Continue?" }); +console.log(answer); From 6d2aa814d376b8243ea2c0b38879732007ec9c55 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Mon, 25 Nov 2024 20:21:58 +0530 Subject: [PATCH 2/8] x --- test.mjs | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 test.mjs diff --git a/test.mjs b/test.mjs deleted file mode 100644 index 8943852217d5c8..00000000000000 --- a/test.mjs +++ /dev/null @@ -1,4 +0,0 @@ -import { confirm } from "npm:@inquirer/prompts"; - -const answer = await confirm({ message: "Continue?" }); -console.log(answer); From 97ea5caefd7b5c99e5d17949a55bf324e2bbe4c7 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Wed, 27 Nov 2024 22:22:14 +0530 Subject: [PATCH 3/8] Add test --- tests/specs/node/stdin_pause/__test__.jsonc | 5 +++++ tests/specs/node/stdin_pause/main.mjs | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 tests/specs/node/stdin_pause/__test__.jsonc create mode 100644 tests/specs/node/stdin_pause/main.mjs diff --git a/tests/specs/node/stdin_pause/__test__.jsonc b/tests/specs/node/stdin_pause/__test__.jsonc new file mode 100644 index 00000000000000..56aa0caa412f8c --- /dev/null +++ b/tests/specs/node/stdin_pause/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run -A main.mjs", + "output": "", + "exitCode": 0 +} diff --git a/tests/specs/node/stdin_pause/main.mjs b/tests/specs/node/stdin_pause/main.mjs new file mode 100644 index 00000000000000..bec0ed9f07e1ad --- /dev/null +++ b/tests/specs/node/stdin_pause/main.mjs @@ -0,0 +1,2 @@ +process.stdin.on("data", () => {}); +process.stdin.pause(); From 25e7d271d73dd380ae38f7c3b905bebd15c9a547 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Thu, 28 Nov 2024 08:03:27 +0530 Subject: [PATCH 4/8] lets goo --- tests/node_compat/runner/TODO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/node_compat/runner/TODO.md b/tests/node_compat/runner/TODO.md index acd5ec45c42865..116226d8a01acd 100644 --- a/tests/node_compat/runner/TODO.md +++ b/tests/node_compat/runner/TODO.md @@ -1,7 +1,7 @@ # Remaining Node Tests -594 tests out of 3681 have been ported from Node 20.11.1 (16.14% ported, 83.97% remaining). +595 tests out of 3681 have been ported from Node 20.11.1 (16.16% ported, 83.94% remaining). NOTE: This file should not be manually edited. Please edit `tests/node_compat/config.json` and run `deno task setup` in `tests/node_compat/runner` dir instead. From 2d8e8a19609ddfcf1c45f63d4ba94584eca8dae6 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 29 Nov 2024 08:42:21 +0530 Subject: [PATCH 5/8] Try this --- tests/specs/node/stdin_pause/main.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/specs/node/stdin_pause/main.mjs b/tests/specs/node/stdin_pause/main.mjs index bec0ed9f07e1ad..6290ff7999b250 100644 --- a/tests/specs/node/stdin_pause/main.mjs +++ b/tests/specs/node/stdin_pause/main.mjs @@ -1,2 +1,2 @@ -process.stdin.on("data", () => {}); +process.stdin.resume(); process.stdin.pause(); From 466012592f92d0a5b6e92007c41d74759b56c3f6 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 29 Nov 2024 16:32:12 +0530 Subject: [PATCH 6/8] yah --- ext/node/polyfills/internal_binding/stream_wrap.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ext/node/polyfills/internal_binding/stream_wrap.ts b/ext/node/polyfills/internal_binding/stream_wrap.ts index 9938b9a85a0cb1..1b9a0d7f34618e 100644 --- a/ext/node/polyfills/internal_binding/stream_wrap.ts +++ b/ext/node/polyfills/internal_binding/stream_wrap.ts @@ -115,7 +115,6 @@ const SUGGESTED_SIZE = 64 * 1024; export class LibuvStreamWrap extends HandleWrap { [kStreamBaseField]?: Reader & Writer & Closer & Ref; - reading!: boolean; #reading = false; destroyed = false; writeQueueSize = 0; @@ -146,6 +145,14 @@ export class LibuvStreamWrap extends HandleWrap { return 0; } + get reading() { + return this.#reading; + } + + set reading(value) { + this.#reading = value; + } + /** * Stop the reading of the stream. * @return An error status code. From a0005e12861a482a99f7c27d5f5dc8bb1567707e Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 29 Nov 2024 17:04:41 +0530 Subject: [PATCH 7/8] what is going on?? --- tests/integration/run_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index 18cded90cb3164..7c0646fd08f9fe 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -3235,7 +3235,7 @@ fn node_process_stdin_unref_with_pty() { ]) .with_pty(|mut console| { // if process.stdin.unref is called, the program immediately ends by skipping reading from stdin. - console.expect("START\r\nEND\r\n"); + console.expect("START\r\nEND\r\n^J"); }); } From 6bee68245151ec7f04d445f5564d1d71e49d6393 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 29 Nov 2024 18:21:26 +0530 Subject: [PATCH 8/8] write --- ext/node/polyfills/internal_binding/stream_wrap.ts | 2 +- tests/integration/run_tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/node/polyfills/internal_binding/stream_wrap.ts b/ext/node/polyfills/internal_binding/stream_wrap.ts index 1b9a0d7f34618e..34724c89a30876 100644 --- a/ext/node/polyfills/internal_binding/stream_wrap.ts +++ b/ext/node/polyfills/internal_binding/stream_wrap.ts @@ -150,7 +150,7 @@ export class LibuvStreamWrap extends HandleWrap { } set reading(value) { - this.#reading = value; + // no-op } /** diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index 7c0646fd08f9fe..18cded90cb3164 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -3235,7 +3235,7 @@ fn node_process_stdin_unref_with_pty() { ]) .with_pty(|mut console| { // if process.stdin.unref is called, the program immediately ends by skipping reading from stdin. - console.expect("START\r\nEND\r\n^J"); + console.expect("START\r\nEND\r\n"); }); }