-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
denoland/fastwebsockets
#72Description
Version: Deno 1.39.0
This is similar to #20948 except that in this case WebSocket.close()
is called from Deno's end.
While #20948 was fixed in #20518, this issue still seems to be reproducible.
This too seems to have regressed somewhere between 1.32.3 and 1.32.4.
To reproduce, run the following with deno run --unstable -A foo.js
:
Deno.serve({hostname: "0.0.0.0", port: 8000}, (request) => {
const url = new URL(request.url);
if (url.pathname == "/") {
return new Response(`
<script>
const url = new URL(location.href);
url.pathname = "/ws";
url.protocol = "ws:";
const ws = new WebSocket(url.href);
</script>
<button onclick="ws.send('close')">close</button>
`, {
headers: {
"Content-Type": "text/html",
}
});
} else if (url.pathname == "/ws") {
const { socket, response } = Deno.upgradeWebSocket(request);
socket.addEventListener("open", () => {
console.log("open");
});
socket.addEventListener("message", () => {
console.log("close");
socket.close();
});
return response;
}
return new Response("not found", {status: 404})
});
Then visit http://localhost:8000/ and click the 'close' button.
The browser console logs:
WebSocket connection to 'ws://localhost:8000/ws' failed: Close received after close
nik-webdevelop, chefnaphtha and arncet
Metadata
Metadata
Assignees
Labels
No labels