Skip to content

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

Description

@dlOuOlb

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.
     Server.prototype.close = function() {
       httpServerPreClose(this);
       ReflectApply(net.Server.prototype.close, this, arguments);
     };

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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