-
Notifications
You must be signed in to change notification settings - Fork 73
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
feat: Close tcp after sending a close frame #72
base: main
Are you sure you want to change the base?
feat: Close tcp after sending a close frame #72
Conversation
I wasn't able to build fastwebsockets on my macbook, so I couldn't run the test suite. But I was able to build deno with these changes and I tested this manually using this script: script
Run with 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);
ws.onclose = (e) => {
console.log("closed", e);
}
</script>
<button onclick="ws.send('close')">request close</button>
<button onclick="ws.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(3123, "custom reason");
});
return response;
}
return new Response("not found", { status: 404 });
}); I also tried this out on two moderately sized projects that make heavy use of websockets, both seemed to run without any issues. Let me know if this is the right approach for this. |
@jespertheend one of the tests is failing: https://github.com/denoland/fastwebsockets/actions/runs/8209255112/job/22459970144?pr=72#step:6:455 |
i hate to be that guy but this is pretty important, error handling on chromium is broken until this gets merged. looks like github purged the test logs, can someone re-run them? |
Last time I checked, this PR fixes the issue, but iirc I couldn't get the tests to pass and I haven't had time to figure out why yet. |
Fixes denoland/deno#21642