Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
awthwathje opened this issue Aug 11, 2022 · 8 comments
Labels
bug Something isn't working
Milestone

Comments

@awthwathje
Copy link

awthwathje commented Aug 11, 2022

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 awthwathje changed the title Closing WebSocket in Durable Object result in Unhandled Promise Rejection: TypeError: WebSocket already closed Closing WebSocket in Durable Object results in Unhandled Promise Rejection: TypeError: WebSocket already closed Aug 11, 2022
@mrbbot
Copy link
Contributor

mrbbot commented Aug 11, 2022

Hey! 👋 Thanks for reporting this. I think I get what's going on here, but would you be able to share a minimal reproduction?

@mrbbot mrbbot added bug Something isn't working question Further information is requested labels Aug 11, 2022
@mrbbot mrbbot added this to the 2.7.0 milestone Aug 11, 2022
@awthwathje
Copy link
Author

Alright, I'll prepare a repo for that.

@awthwathje
Copy link
Author

I'm holding up this issue for now, since I am preparing a repo for the Wrangler team on another related issue. I'll get back here once that is sorted.

@awthwathje
Copy link
Author

You know what @mrbbot? I'll close this issue here for now. Since you're active in Wrangler2, I'll recreate it there once I get to the point of WebSocket connections working with the most recent Wrangler (there are quite some bugs left). I'll recreate this issue there, if it's still the case. Thanks!

@awthwathje
Copy link
Author

Hey @mrbbot I moved out to vanilla Miniflare, so I am reopening this issue.

Here is the reproduction repo you asked for: https://github.com/awthwathje/miniflare-debug-example

@awthwathje awthwathje reopened this Sep 6, 2022
@mrbbot
Copy link
Contributor

mrbbot commented Sep 10, 2022

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

@mrbbot mrbbot removed the question Further information is requested label Sep 10, 2022
@mrbbot mrbbot modified the milestones: 2.7.0, 2.9.0 Sep 10, 2022
@mrbbot mrbbot closed this as completed in 14d92e8 Sep 10, 2022
@awthwathje
Copy link
Author

Thanks for fixing @mrbbot! Appreciated! ❤️

@mrbbot
Copy link
Contributor

mrbbot commented Sep 17, 2022

Hey! 👋 Miniflare 2.9.0 has just been released, which implements this fix. You can find the full changelog here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants