fix(node): add http.Server.unref() (#19201)

Closes https://github.com/denoland/deno/issues/19113
This commit is contained in:
Bartek Iwańczuk 2023-05-22 01:02:10 +02:00 committed by GitHub
parent 9ec4989776
commit 40bda07ff5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 2 deletions

View file

@ -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);
});