pass test/js/node/test/parallel/test-https-server-close-destroy-timeout.js

This commit is contained in:
Ciro Spaciari
2025-04-23 20:02:07 -07:00
parent 0abf0a9281
commit faf1bc56a1
2 changed files with 28 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ const { format } = require("internal/util/inspect");
const { IncomingMessage } = require("node:_http_incoming");
const { OutgoingMessage } = require("node:_http_outgoing");
const { kIncomingMessage } = require("node:_http_common");
const kConnectionsCheckingInterval = Symbol("http.server.connectionsCheckingInterval");
const getBunServerAllClosedPromise = $newZigFunction("node_http_binding.zig", "getBunServerAllClosedPromise", 1);
const sendHelper = $newZigFunction("node_cluster_binding.zig", "sendHelperChild", 3);
@@ -709,6 +710,7 @@ const ServerPrototype = {
__proto__: EventEmitter.prototype,
[kIncomingMessage]: undefined,
[kServerResponse]: undefined,
[kConnectionsCheckingInterval]: { _destroyed: false },
ref() {
this._unref = false;
this[serverSymbol]?.ref?.();
@@ -741,6 +743,7 @@ const ServerPrototype = {
return;
}
this[serverSymbol] = undefined;
this[kConnectionsCheckingInterval]._destroyed = true;
if (typeof optionalCallback === "function") setCloseCallback(this, optionalCallback);
server.stop();
},
@@ -1721,4 +1724,5 @@ function ensureReadableStreamController(run) {
export default {
Server,
ServerResponse,
kConnectionsCheckingInterval,
};

View File

@@ -0,0 +1,24 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
}
const { createServer } = require('https');
const { kConnectionsCheckingInterval } = require('_http_server');
const fixtures = require('../common/fixtures');
const options = {
key: fixtures.readKey('agent1-key.pem'),
cert: fixtures.readKey('agent1-cert.pem')
};
const server = createServer(options, function(req, res) {});
server.listen(0, common.mustCall(function() {
assert.strictEqual(server[kConnectionsCheckingInterval]._destroyed, false);
server.close(common.mustCall(() => {
assert(server[kConnectionsCheckingInterval]._destroyed);
}));
}));