MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / close

Method close

src/remote/SessionsWebSocket.ts:369–387  ·  view source on GitHub ↗

* Close the WebSocket connection

()

Source from the content-addressed store, hash-verified

367 * Close the WebSocket connection
368 */
369 close(): void {
370 logForDebugging('[SessionsWebSocket] Closing connection')
371 this.state = 'closed'
372 this.stopPingInterval()
373
374 if (this.reconnectTimer) {
375 clearTimeout(this.reconnectTimer)
376 this.reconnectTimer = null
377 }
378
379 if (this.ws) {
380 // Null out event handlers to prevent race conditions during reconnect.
381 // Under Bun (native WebSocket), onX handlers are the clean way to detach.
382 // Under Node (ws package), the listeners were attached with .on() in connect(),
383 // but since we're about to close and null out this.ws, no cleanup is needed.
384 this.ws.close()
385 this.ws = null
386 }
387 }
388
389 /**
390 * Force reconnect - closes existing connection and establishes a new one.

Callers 1

reconnectMethod · 0.95

Calls 3

stopPingIntervalMethod · 0.95
closeMethod · 0.65
logForDebuggingFunction · 0.50

Tested by

no test coverage detected