Skip to content

Shutdown hangs indefinitely on Windows when WebSocket is connected, even with graceful shutdown #1045

@thomasjm

Description

@thomasjm

I found that on Windows, the graceful shutdown timeout seems not to be respected when a WebSocket connection is active.

I made a repro project at https://github.com/thomasjm/websocket-teardown-repro. When you clone this and do stack run, it starts a Warp server with a single WebSocket endpoint. This endpoint will just echo messages. It uses a graceful shutdown timeout of 1 second.

Starting WebSocket echo server on port 8080
WebSocket endpoint available at: ws://localhost:8080/socket

If you then proceed to Ctrl+C the server, it shuts down immediately:

Shutting down due to SIGINT...
Network.Socket.accept: failed (Interrupted function call (WSAEINTR))

This is fine, other than the odd error message about WSAEINTR which doesn't happen on Linux.

However, if you start the server and then in a separate terminal do websocat ws://localhost:8080/socket, then Ctrl+C will not shut down the server, and it will hang indefinitely after printing the same message as before. A second Ctrl+C will finish it though.

This is reminiscent of #839, #853, and #979. However, unlike all those issues, it results in the server hanging indefinitely, which I think makes it more serious as a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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