// Miniflare answers an unstubbed upgrade on a socket without an error listener, and a reset at // teardown crashes the test run. Answer unstubbed WebSocket upgrades here instead. const fetch = globalThis.fetch; globalThis.fetch = async (input, init) => { const request = new Request(input, init); if (request.headers.get("Upgrade")?.toLowerCase() === "websocket") { return new Response(`unexpected upgrade: ${request.url}`, { status: 599 }); } return await fetch(request); };