Skip to content

Closing a socket with a pending read makes Windows send a TCP RST packet #3034

Description

@mmomtchev
  • Version: 1.40.0 (node-master)
  • Platform: Windows 10

shutdown(tcp->socket, SD_SEND);

On Windows, according to this comment, shutting down the transmit side of a socket should allow for an immediate graceful shutdown with closesocket - however this is not what I am observing. What I am observing is a TCP RST packet that goes away if I delay the shutdown to uv_tcp_endgame with close_socket = 0.

This can be easily reproduced with res.end() from Node - test/parallel/test-https-truncate.js is a very good example. The connection gets closed by a TCP RST by the server.

I wonder if Node should work around this issue or if it should be fixed in libuv. Normally, it is up to libuv to ensure that the socket is gracefully closed? Or is Node that should ensure that no reads are pending?

nodejs/node#35946
nodejs/node#35904

There is also a very similar issue on OSX for which I will create another issue when I am done digging, it looks like it is related to the default lingering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    not-staleIssues that should never be marked stale

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions