Skip to content

https.Server does not call http.close #48373

Closed
@mm-mbinder

Description

@mm-mbinder

Version

v18.7.0

Platform

Linux ubuntu 5.15.0-73-generic #80~20.04.1-Ubuntu SMP Wed May 17 14:58:14 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

https

What steps will reproduce the bug?

Running this script:

const http = require('http');
const https = require('https');

const httpServer = http.createServer({});
const httpsServer = https.createServer({});

httpServer.listen(9900, () => {
        console.log('HTTP Server before close:', httpServer);

        httpServer.close(() => {
                console.log('HTTP Server after close:', httpServer);
        });
});

httpsServer.listen(9901, () => {
        console.log('HTTPS Server before close:', httpsServer);

        httpsServer.close(() => {
                console.log('HTTPS Server after close:', httpsServer);
        });
});

How often does it reproduce? Is there a required condition?

It occurs on Node Versions >= 18 as far as i can tell.

What is the expected behavior? Why is that the expected behavior?

Calling https.Server.close should also call http.Server.close to cleanup the connectionsCheckingInterval (at least that's what the docs are suggesting).

What do you see instead?

The connectionsCheckingInterval of an https.Server is not cleaned up.
See this output:

HTTP Server before close: <ref *1> Server {
  // ...
  [Symbol(http.server.connectionsCheckingInterval)]: Timeout {
    _idleTimeout: 30000,
    _idlePrev: [Timeout],
    _idleNext: [TimersList],
    _idleStart: 23,
    _onTimeout: [Function: bound checkConnections],
    _timerArgs: undefined,
    _repeat: 30000,
    _destroyed: false,
    [Symbol(refed)]: false,
    [Symbol(kHasPrimitive)]: false,
    [Symbol(asyncId)]: 2,
    [Symbol(triggerId)]: 1
  },
  [Symbol(kUniqueHeaders)]: null
}
HTTPS Server before close: <ref *1> Server {
  // ...
  [Symbol(http.server.connectionsCheckingInterval)]: Timeout {
    _idleTimeout: 30000,
    _idlePrev: [TimersList],
    _idleNext: [TimersList],
    _idleStart: 52,
    _onTimeout: [Function: bound checkConnections],
    _timerArgs: undefined,
    _repeat: 30000,
    _destroyed: false,
    [Symbol(refed)]: false,
    [Symbol(kHasPrimitive)]: false,
    [Symbol(asyncId)]: 3,
    [Symbol(triggerId)]: 1
  }
}
HTTP Server after close: Server {
  // ...
  [Symbol(http.server.connectionsCheckingInterval)]: Timeout {
    _idleTimeout: -1,
    _idlePrev: null,
    _idleNext: null,
    _idleStart: 23,
    _onTimeout: null,
    _timerArgs: undefined,
    _repeat: 30000,
    _destroyed: true, // <--- expected
    [Symbol(refed)]: false,
    [Symbol(kHasPrimitive)]: false,
    [Symbol(asyncId)]: 2,
    [Symbol(triggerId)]: 1
  },
  [Symbol(kUniqueHeaders)]: null
}
HTTPS Server after close: Server {
  // ...
  [Symbol(http.server.connectionsCheckingInterval)]: Timeout {
    _idleTimeout: 30000,
    _idlePrev: [TimersList],
    _idleNext: [TimersList],
    _idleStart: 52,
    _onTimeout: [Function: bound checkConnections],
    _timerArgs: undefined,
    _repeat: 30000,
    _destroyed: false, // <--- unexpected
    [Symbol(refed)]: false,
    [Symbol(kHasPrimitive)]: false,
    [Symbol(asyncId)]: 3,
    [Symbol(triggerId)]: 1
  }
}

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions