Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ OutgoingMessage.prototype.destroy = function destroy(error) {
});
}

if (this instanceof OutgoingMessage) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this if required?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to check for instances where no sockets were constructed, as in msg = new OutgoingMessage (similar to the code snippet in the original issue #33653).

process.nextTick(() => {
this.emit('close');
});
Comment thread
rexagod marked this conversation as resolved.
Resolved
}
return this;
};

Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-http-outgoing-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const OutgoingMessage = http.OutgoingMessage;
assert.strictEqual(msg.destroyed, false);
msg.destroy();
assert.strictEqual(msg.destroyed, true);
msg.on('close', common.mustCall(() => {
assert.strictEqual(msg.destroyed, true);
}));
let callbackCalled = false;
msg.write('asd', common.mustCall((err) => {
assert.strictEqual(err.code, 'ERR_STREAM_DESTROYED');
Expand Down