node icon indicating copy to clipboard operation
node copied to clipboard

`http.Server.close` return value mismatch between the documentation and the implementation.

Open dlOuOlb opened this issue 1 year ago • 0 comments

Version

v21.6.2

Platform

Microsoft Windows NT 10.0.19045.0 x64

Subsystem

No response

What steps will reproduce the bug?

import * as http from 'node:http';

const server = http.createServer();

console.info(server === server.close());

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

It seems to reproduce unconditionally, with just node "the-above-snippet.js".

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

The output should be:

true

Because the documentation says:

Where the returned server instance seems to be intended to be the server instance to close.

What do you see instead?

false

Because server.close() returned undefined.

Additional information

  • It seems that the following implementation needs a proper return statement.
    erver.prototype.close = function() {
     httpServerPreClose(this);
     ReflectApply(net.Server.prototype.close, this, arguments);
    ;
    

dlOuOlb avatar Feb 17 '24 03:02 dlOuOlb