miniflare icon indicating copy to clipboard operation
miniflare copied to clipboard

Closing WebSocket in Durable Object results in Unhandled Promise Rejection: TypeError: WebSocket already closed

Open awthwathje opened this issue 2 years ago • 0 comments

Miniflare version: 2.6.0

While closing the WebSocket from the client side, it is expected to close it in the Durable Object right after, otherwise it won't be closed. So closing negotiation goes like: Client > DO > Client.

Miniflare however throws Unhandled Promise Rejection: TypeError: WebSocket already closed error when Durable Object tries to close the socket when the 'close' event is received from the client.

Apparently, with Miniflare the client is able to close the socket prematurely without waiting for the Durable Object to close the server socket first.

awthwathje avatar Aug 11 '22 00:08 awthwathje