summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit_node/process_test.ts19
-rw-r--r--cli/tests/unit_node/testdata/process_really_exit.ts10
-rw-r--r--ext/node/polyfills/process.ts9
3 files changed, 37 insertions, 1 deletions
diff --git a/cli/tests/unit_node/process_test.ts b/cli/tests/unit_node/process_test.ts
index 686a3dbbc..49b753db3 100644
--- a/cli/tests/unit_node/process_test.ts
+++ b/cli/tests/unit_node/process_test.ts
@@ -727,3 +727,22 @@ Deno.test({
assertEquals(stripColor(decoder.decode(stdout).trim()), "exit");
},
});
+
+Deno.test({
+ name: "process.reallyExit",
+ async fn() {
+ const command = new Deno.Command(Deno.execPath(), {
+ args: [
+ "run",
+ "--quiet",
+ "--unstable",
+ "./testdata/process_really_exit.ts",
+ ],
+ cwd: testDir,
+ });
+ const { stdout } = await command.output();
+
+ const decoder = new TextDecoder();
+ assertEquals(stripColor(decoder.decode(stdout).trim()), "really exited");
+ },
+});
diff --git a/cli/tests/unit_node/testdata/process_really_exit.ts b/cli/tests/unit_node/testdata/process_really_exit.ts
new file mode 100644
index 000000000..16f30b33d
--- /dev/null
+++ b/cli/tests/unit_node/testdata/process_really_exit.ts
@@ -0,0 +1,10 @@
+import process from "node:process";
+
+//deno-lint-ignore no-undef
+// @ts-ignore - Node typings don't even have this because it's
+// been deprecated for 4 years. But it's used in `signal-exit`,
+// which in turn is used in `node-tap`.
+process.reallyExit = function () {
+ console.info("really exited");
+};
+process.exit();
diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts
index 2dc10d7b1..b676e87d7 100644
--- a/ext/node/polyfills/process.ts
+++ b/ext/node/polyfills/process.ts
@@ -91,7 +91,7 @@ export const exit = (code?: number | string) => {
process.emit("exit", process.exitCode || 0);
}
- Deno.exit(process.exitCode || 0);
+ process.reallyExit(process.exitCode || 0);
};
function addReadOnlyProcessAlias(
@@ -380,6 +380,13 @@ class Process extends EventEmitter {
/** https://nodejs.org/api/process.html#process_process_exit_code */
exit = exit;
+ // Undocumented Node API that is used by `signal-exit` which in turn
+ // is used by `node-tap`. It was marked for removal a couple of years
+ // ago. See https://github.com/nodejs/node/blob/6a6b3c54022104cc110ab09044a2a0cecb8988e7/lib/internal/bootstrap/node.js#L172
+ reallyExit = (code: number) => {
+ return Deno.exit(code || 0);
+ };
+
_exiting = _exiting;
/** https://nodejs.org/api/process.html#processexitcode_1 */