MCPcopy Index your code
hub / github.com/coder/coder / handleDisconnect

Function handleDisconnect

site/src/utils/reconnectingWebSocket.ts:256–274  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

254 };
255
256 const handleDisconnect = () => {
257 // Guard against duplicate calls: browsers fire both "error"
258 // and "close" on a failed WebSocket, so we only process the
259 // first event per socket instance.
260 if (activeSocket !== socket || disposed) {
261 return;
262 }
263 activeSocket = null;
264 const reconnect = getReconnectSchedule({
265 attempt: lastReconnectAttempt + 1,
266 baseMs,
267 maxMs,
268 factor,
269 jitter,
270 random,
271 });
272 onDisconnect?.(reconnect);
273 scheduleReconnect(reconnect);
274 };
275
276 socket.addEventListener("open", handleOpen);
277 socket.addEventListener("error", handleDisconnect);

Callers

nothing calls this directly

Calls 3

getReconnectScheduleFunction · 0.85
scheduleReconnectFunction · 0.85
onDisconnectFunction · 0.50

Tested by

no test coverage detected