© 2026 Hedgehog Software, LLC
// Retrieve or initialize ipInfo for this IP const ipInfo = this.ipData.get(ip) || { connection: [], message: [], pong: [], initialPingTimeout: null, pongReceived: false, serverInstance: null };
const websocket = new WebSocket('ws://localhost:8787/websocket');
//handle previous server instance if exists if( ipInfo.serverInstance && ipInfo.serverInstance.readyState === 1 && ipInfo.serverInstance !== server ){ try{ console.log('before: ',ipInfo.serverInstance.readyState) ipInfo.serverInstance.close(1000,'Closing previous connection') console.log('after: ',ipInfo.serverInstance.readyState) }catch(e){} } //assign current server instance to map ipInfo.serverInstance = server //... this.ipData.set(ip, ipInfo);
ipInfo.serverInstance.close
before: 1 after: 2 [wrangler:inf] GET /websocket 101 Switching Protocols (3ms) ✘ [ERROR] Uncaught (in response) Error: Network connection lost. ✘ [ERROR] workerd/server/server.c++:3069: error: Uncaught exception: kj/async.c++:212: disconnected: worker_do_not_log; Request failed due to internal error