Hello 👋
When using partyserver, a client-initiated WebSocket close reaches webSocketClose / onClose, but the client stays stuck in CLOSING and the connection timeouts where it should be gracefully closed by the server.
Repro
Minimal repro: https://github.com/ThomasKliszowski/partyserver-close-repro
Run:
Then:
$ pnpm client
...
Client sends close(1000, "client initiated close")
Timed out after 2500ms waiting for the client close to finish. readyState=CLOSING
The server does receive the close event:
onClose {
code: 1000,
reason: 'client initiated close',
wasClean: true,
readyState: 2
}
But doesn't close the client's ws.
Excepted
$ pnpm client:ack
...
Client sends close(1000, "client initiated close")
Client received close event: code=1000, reason="client initiated close", readyState=CLOSED
Suspected Location
We never close the client's connection here:
https://github.com/cloudflare/partykit/blob/main/packages/partyserver/src/index.ts#L502-L525
(or in this.onClose depending on where you want to handle that)
Please let me know if you have any questions, thank you for looking into that 🙏
Hello 👋
When using
partyserver, a client-initiated WebSocket close reacheswebSocketClose/onClose, but the client stays stuck inCLOSINGand the connection timeouts where it should be gracefully closed by the server.Repro
Minimal repro: https://github.com/ThomasKliszowski/partyserver-close-repro
Run:
Then:
The server does receive the close event:
But doesn't close the client's
ws.Excepted
Suspected Location
We never close the client's connection here:
https://github.com/cloudflare/partykit/blob/main/packages/partyserver/src/index.ts#L502-L525
(or in
this.onClosedepending on where you want to handle that)Please let me know if you have any questions, thank you for looking into that 🙏