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

Function shutdown

src/services/lsp/LSPServerManager.ts:157–185  ·  view source on GitHub ↗

* Shutdown all running servers and clear state. * Only servers in 'running' state are explicitly stopped; * servers in other states are cleared without shutdown. * * @throws {Error} If one or more servers fail to stop

()

Source from the content-addressed store, hash-verified

155 * @throws {Error} If one or more servers fail to stop
156 */
157 async function shutdown(): Promise<void> {
158 const toStop = Array.from(servers.entries()).filter(
159 ([, s]) => s.state === 'running' || s.state === 'error',
160 )
161
162 const results = await Promise.allSettled(
163 toStop.map(([, server]) => server.stop()),
164 )
165
166 servers.clear()
167 extensionMap.clear()
168 openedFiles.clear()
169
170 const errors = results
171 .map((r, i) =>
172 r.status === 'rejected'
173 ? `${toStop[i]![0]}: ${errorMessage(r.reason)}`
174 : null,
175 )
176 .filter((e): e is string => e !== null)
177
178 if (errors.length > 0) {
179 const err = new Error(
180 `Failed to stop ${errors.length} LSP server(s): ${errors.join('; ')}`,
181 )
182 logError(err)
183 throw err
184 }
185 }
186
187 /**
188 * Get the LSP server instance for a given file path.

Callers

nothing calls this directly

Calls 5

entriesMethod · 0.80
stopMethod · 0.65
errorMessageFunction · 0.50
logErrorFunction · 0.50
clearMethod · 0.45

Tested by

no test coverage detected