Skip to content

[memory leak] Sockets / streams: end() / final() vs destroy() - which one cleans up the stream? #1338

@theogravity

Description

@theogravity

I noticed that destroy() was added in node 8.

After reading through the docs for both, I'm not entirely clear which I should be calling, especially if I'm concerned about memory leaks.

destroy() seems to do some extra stuff, including triggering the error event if an error is defined.

It also seems that I should be using destroy() when I'm using duplex streams once I'm completely done with the stream in general (eg I'm done with both the read/write side, it's better than having to remember to call end()/final() individually.)

I'm asking with respect to generic streams, but also when using http.ClientRequest (do I need to call it in the res object after I get the end event from the server?).

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