summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-05-22 01:02:10 +0200
committerGitHub <noreply@github.com>2023-05-22 01:02:10 +0200
commit40bda07ff5751cbb2665a2d134f64826fe3790a8 (patch)
tree6b7527ec463551ba86bd20d640616e39f4e2e461 /cli
parent9ec49897766d9c22f6c7bafabdd3e3f3a4b68ab1 (diff)
fix(node): add http.Server.unref() (#19201)
Closes https://github.com/denoland/deno/issues/19113
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/unit_node/http_test.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts
index 08d2626d7..e7d743dde 100644
--- a/cli/tests/unit_node/http_test.ts
+++ b/cli/tests/unit_node/http_test.ts
@@ -12,6 +12,7 @@ import { deferred } from "../../../test_util/std/async/deferred.ts";
import { gzip } from "node:zlib";
import { Buffer } from "node:buffer";
import { serve } from "../../../test_util/std/http/server.ts";
+import { execCode } from "../unit/test_util.ts";
Deno.test("[node/http listen]", async () => {
{
@@ -461,3 +462,21 @@ Deno.test("[node/http] ServerResponse _implicitHeader", async () => {
await d;
});
+
+Deno.test("[node/http] server unref", async () => {
+ const [statusCode, _output] = await execCode(`
+ import http from "node:http";
+ const server = http.createServer((_req, res) => {
+ res.statusCode = status;
+ res.end("");
+ });
+
+ // This should let the program to exit without waiting for the
+ // server to close.
+ server.unref();
+
+ server.listen(async () => {
+ });
+ `);
+ assertEquals(statusCode, 0);
+});