Issue 1:
perf(ext/websocket): replace tokio_tungstenite server with fastwebsockets #18587

The above commit seems to break websockets.

Symptom: websocket sends do not go through until new messages arrive to the connection.

It's easy to reproduce with example close to the one from https://medium.com/deno-the-complete-reference/native-web-sockets-client-server-in-deno-928678a65cf2 replacing prompts to input text with setTimeout with sending ping-pongs.

//chat_server.ts

import { serve } from "https://deno.land/std/http/mod.ts";
function logError(msg: string) {
console.log(msg);
Deno.exit(1);
}
function handleConnected() {
console.log("Connected to client ...");
}
function handleMessage(ws: WebSocket, data: string) {
console.log("CLIENT >> " + data);
setTimeout(()=>ws.send('pong'),2000);
// const reply = prompt("Server >> ") || "No reply";
// if (reply === "exit") {
// return ws.close();
// }
// ws.send(reply as string);
}
function handleError(e: Event | ErrorEvent) {
console.log(e instanceof ErrorEvent ? e.message : e.type);
}
async function reqHandler(req: Request) {
if (req.headers.get("upgrade") != "websocket") {
return new Response(null, { status: 501 });
}
const { socket: ws, response } = Deno.upgradeWebSocket(req);
ws.onopen = () => handleConnected();
ws.onmessage = (m) => handleMessage(ws, m.data);
ws.onclose = () => logError("Disconnected from client ...");
ws.onerror = (e) => handleError(e);
return response;
}
console.log("Waiting for client ...");
serve(reqHandler, { port: 8001 });

//chat_client.ts

function logError(msg: string) {
console.log(msg);
Deno.exit(1);
}
function handleConnected(ws: WebSocket) {
console.log("Connected to server ...");
handleMessage(ws, "Welcome!");
}
function handleMessage(ws: WebSocket, data: string) {
console.log("SERVER >> " + data);
setTimeout(()=>ws.send('ping'),2000);
// const reply = prompt("Client >> ") || "No reply";
// if (reply === "exit") {
// return ws.close();
// }
// ws.send(reply as string);
}
function handleError(e: Event | ErrorEvent) {
console.log(e instanceof ErrorEvent ? e.message : e.type);
}
console.log("Connecting to server ...");
try {
const ws = new WebSocket("ws://localhost:8001");
ws.onopen = () => handleConnected(ws);
ws.onmessage = (m) => handleMessage(ws, m.data);
ws.onclose = () => logError("Disconnected from server ...");
ws.onerror = (e) => handleError(e);
} catch (err) {
logError("Failed to connect to server ... exiting");
}

This example sends ping-pongs every 2 seconds on 1.32.3, but stalls on 1.32.4

Issue 2:
Today, I upgrade deno to 1.32.4. Websocket break in deno 1.32.4.

First message successfully send but cannot send message after timeout.

It work fine in deno 1.32.3.

const { socket, response } = Deno.upgradeWebSocket(reqEvent.request);
socket.onopen = () => {
console.log("socket opened");
socket.send("Hello World!");
};
socket.onmessage = (e) => {
socket.send("message from client received");//this work
setTimeout(() => {
socket.send("message send after some time");//this doesn't work
// socket.close();
}, 2000);
};
socket.onclose = () => console.log("WebSocket has been closed.");
socket.onerror = (e) => console.error("WebSocket error:", e);
reqEvent.respondWith(response);

please fix this issue.