MCPcopy
hub / github.com/codeaashu/claude-code / destroy

Method destroy

src/server/web/session-store.ts:125–156  ·  view source on GitHub ↗

* Immediately kill the PTY and remove the session.

(token: string)

Source from the content-addressed store, hash-verified

123 * Immediately kill the PTY and remove the session.
124 */
125 destroy(token: string): void {
126 const session = this.sessions.get(token);
127 if (!session) return;
128
129 this.sessions.delete(token);
130
131 if (session.graceTimer) {
132 clearTimeout(session.graceTimer);
133 session.graceTimer = null;
134 }
135
136 if (
137 session.ws &&
138 session.ws.readyState !== 2 /* CLOSING */ &&
139 session.ws.readyState !== 3 /* CLOSED */
140 ) {
141 session.ws.close(1000, "Session destroyed");
142 }
143
144 try {
145 session.pty.kill("SIGHUP");
146 } catch {
147 // PTY may already be dead
148 }
149 setTimeout(() => {
150 try {
151 session.pty.kill("SIGKILL");
152 } catch {
153 // Already dead
154 }
155 }, 5000);
156 }
157
158 /** Returns summary info for all sessions (used by the REST API). */
159 list(): SessionInfo[] {

Callers 13

startGraceMethod · 0.95
destroyAllMethod · 0.95
streamOnDataFunction · 0.45
checkIdeConnectionFunction · 0.45
execCommandHookFunction · 0.45
handleEPIPEFunction · 0.45
stopMethod · 0.45
handleMcpClientMethod · 0.45
connectVoiceStreamFunction · 0.45
growthbook.tsFile · 0.45
resetGrowthBookFunction · 0.45
wirePtyEventsMethod · 0.45

Calls 4

getMethod · 0.65
deleteMethod · 0.65
closeMethod · 0.45
killMethod · 0.45

Tested by

no test coverage detected