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

Websockets sometimes try to close with 1005 #284

Closed
hansottowirtz opened this issue Jun 14, 2022 · 1 comment
Closed

Websockets sometimes try to close with 1005 #284

hansottowirtz opened this issue Jun 14, 2022 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@hansottowirtz
Copy link
Contributor

I'm trying to use Cloudflare Tunnel to connect to a Postgres database, which I believe uses WebSockets under the hood. Sometimes, WebSockets try to close with code 1005, resulting in an error:

First argument must be a valid error code number

pair.addEventListener("close", (e) => {
if (ws.readyState < StandardWebSocket.CLOSING) ws.close(e.code, e.reason);
});

Replacing this with:

ws.close(e.code === 1005 ? 1000 : e.code, e.reason);

seems to solve the problem, but I'm not sure whether there's an underlying issue in WebSocketPair or not.

@mrbbot mrbbot added the bug Something isn't working label Jun 15, 2022
@mrbbot mrbbot added this to the 2.6.0 milestone Jun 15, 2022
@mrbbot mrbbot closed this as completed in 2c31183 Jun 15, 2022
@mrbbot
Copy link
Contributor

mrbbot commented Jun 15, 2022

Hey! 👋 Thanks for raising this. Will be fixed in the next release. 🙂

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