Skip to content

No error is emitted on response destroy when socket is already destroyed #35923

Closed as not planned
@szmarczak

Description

  • Version: 10.x.x, 12.x.x, 14.x.x, 15.x.x
  • Platform: Linux solus 5.6.19-159.current #1 SMP PREEMPT Fri Oct 16 17:49:06 UTC 2020 x86_64 GNU/Linux
  • Subsystem: http

What steps will reproduce the bug?

const http = require('http');

const request = http.get('http://httpbin.org/anything', response => {
    setTimeout(() => {
        console.log(`request.destroyed = ${request.destroyed}`);
        console.log(`response.destroyed = ${response.destroyed}`);
        
        response.destroy(new Error('failure'));
    }, 1000);
});

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

Always.

What is the expected behavior?

An error with a message failure.

What do you see instead?

No error.

Additional information

While I understand that request is destroyed on socket close, the response.destroy logic is broken:

node/lib/_http_incoming.js

Lines 121 to 125 in c1da528

IncomingMessage.prototype.destroy = function destroy(error) {
if (this.socket)
this.socket.destroy(error);
return this;
};

The error is not thrown because the socket has been destroyed. Although the response has not.

Activity

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

Metadata

Assignees

No one assigned

    Labels

    httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions