Skip to content

IncomingMessage docs incorrect #41011

Closed
@ronag

Description

@ronag

nodejs/undici#1115

We have missed updating the docs.

This property is guaranteed to be an instance of the <net.Socket> class, a subclass of <stream.Duplex>, unless the user specified a socket type other than <net.Socket>.

Is no longer true. It will be null after detach and destroy.

node/lib/_http_server.js

Lines 246 to 250 in 265a47d

ServerResponse.prototype.detachSocket = function detachSocket(socket) {
assert(socket._httpMessage === this);
socket.removeListener('close', onServerResponseClose);
socket._httpMessage = null;
this.socket = null;

node/lib/_http_client.js

Lines 661 to 666 in 265a47d

req.destroyed = true;
if (req.res) {
// Detach socket from IncomingMessage to avoid destroying the freed
// socket in IncomingMessage.destroy().
req.res.socket = null;
}

if (isServerRequest(stream)) {
stream.socket = null;
stream.destroy(err);

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.good first issueIssues that are suitable for first-time contributors.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