{"record":{"id":"92b4c49c10a42c91","repo":"neoclide/coc.nvim","slug":"stopping-the-server-timed-out","errorCode":null,"errorMessage":"Stopping the server timed out","messagePattern":"Stopping the server timed out","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/language-client/client.ts","lineNumber":1381,"sourceCode":"    })(connection)\n    // If the connection closes while the shutdown is in flight (e.g. the\n    // server crashed), handleConnectionClosed signals it here so the stop\n    // completes successfully: the server is gone, which is the outcome the\n    // caller asked for. Without this, the pending shutdown rejects after the\n    // connection is disposed, reporting a false stop failure.\n    const close = new Promise<Connection>(resolve => {\n      this._onStopClose = () => resolve(connection)\n    })\n\n    return this._onStop = Promise.race([tp, shutdown, close]).then(connection => {\n      if (tm) clearTimeout(tm)\n      // The connection won the race with the timeout.\n      if (connection !== undefined) {\n        connection.end()\n        connection.dispose()\n      } else {\n        this.error(`Stopping server timed out`, undefined)\n        throw new Error(`Stopping the server timed out`)\n      }\n    }, error => {\n      this.error(`Stopping server failed`, error)\n      throw error\n    }).finally(() => {\n      this.$state = ClientState.Stopped\n      if (mode === 'stop') {\n        this.cleanUpChannel()\n      }\n      this._onStart = undefined\n      this._onStop = undefined\n      this._onStopClose = undefined\n      this._connection = undefined\n      this._ignoredRegistrations.clear()\n    })\n  }\n\n  public dispose(timeout = 2000): Promise<void> {","sourceCodeStart":1363,"sourceCodeEnd":1399,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/language-client/client.ts#L1363-L1399","documentation":"BaseLanguageClient.stop() waits for the server connection to end within a timeout window. If the connection has not been ended when the timeout fires, the client logs 'Stopping server timed out' and throws so callers know shutdown did not complete cleanly. The state is still forced to Stopped in the finally block.","triggerScenarios":"Calling client.stop() (or extension deactivate) while the language server process hangs, ignores the shutdown request, or takes longer than the shutdown timeout (default 1s, configurable via a requestTimeout/shutdown timeout option).","commonSituations":"A server that never responds to the LSP 'shutdown' request, a server blocked on I/O or a deadlock, slow teardown on Windows where process kill is asynchronous, or an extension deactivating while a request is still in flight.","solutions":["Check the server implementation responds to the shutdown/exit requests promptly","Increase the shutdown timeout passed to the client constructor options","Kill leftover server processes manually and retry stopping","Update or replace the misbehaving language server"],"exampleFix":"// before\nawait client.stop()\n// after\ntry {\n  await client.stop()\n} catch (e) {\n  // server ignored shutdown; state is already Stopped\n  console.warn('Server did not shut down cleanly:', e)\n}","handlingStrategy":"try-catch","validationCode":"// No pre-call validation; ensure server supports shutdown before stop\n// e.g. check capabilities negotiated during initialize contain shutdown support","typeGuard":null,"tryCatchPattern":"try {\n  await client.stop()\n} catch (e) {\n  if (String(e.message).includes('Stopping the server timed out')) {\n    // force-kill leftover server process; client state is already Stopped\n  } else { throw e }\n}","preventionTips":["Choose language servers that implement shutdown/exit correctly","Set an adequate shutdown timeout in client options","Avoid calling stop() while long requests are in flight","Monitor for orphaned server processes after deactivation"],"tags":["lifecycle","shutdown","timeout","language-server"],"backgroundTag":"server-shutdown-timeout","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}