question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
mrbbotcommented, Sep 10, 2022

Hey! 👋 Thanks for the repo! 🙂 I’m able to reproduce the issue, and will have a go at fixing this soon. 👍

1reaction
awthwathjecommented, Aug 11, 2022

Alright, I’ll prepare a repo for that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - How to catch and deal with "WebSocket is already ...
The easiest way is to check if the socket is open or not before sending. For example - write a simple function: function...
Read more >
Changelog - Miniflare
Ensure calling WebSocket#close() before returning a WebSocket response sends the correct close code and reason. Fix delivery of incoming WebSocket error events ...
Read more >
Event-Driven and Asynchronous Programming with Python
This check is necessary because closed connections are represented as read events, so a read handler run immediately prior might remove a closed...
Read more >
closing websockets : r/ComputerCraft - Reddit
Is there a way to close web sockets when a program is terminated? I know you use ws.close() to close them normally, but...
Read more >
Node.js 8 the Right Way - Library IT
Node.js 8 the Right Way is an excellent guide for building robust Node.js applica- ... The special URL beginning with ws:// is a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found