{"record":{"id":"d66c974a1c2033a8","repo":"neoclide/coc.nvim","slug":"client-is-currently-stopping-can-only-restart-a-f","errorCode":null,"errorMessage":"Client is currently stopping. Can only restart a full stopped client","messagePattern":"Client is currently stopping\\. Can only restart a full stopped client","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/language-client/client.ts","lineNumber":992,"sourceCode":"  }\n\n  public get started(): boolean {\n    return this.$state != ClientState.Initial\n  }\n\n  public isRunning(): boolean {\n    return this.$state === ClientState.Running\n  }\n  /**\n   * @internal\n   */\n\n  public async _start(): Promise<void> {\n    if (this._disposed === 'disposing' || this._disposed === 'disposed') {\n      throw new Error(`Client got disposed and can't be restarted.`)\n    }\n    if (this.$state === ClientState.Stopping) {\n      throw new Error(`Client is currently stopping. Can only restart a full stopped client`)\n    }\n    // We are already running or are in the process of getting up\n    // to speed.\n    if (this._onStart !== undefined) {\n      return this._onStart\n    }\n    this._rootPath = this.resolveRootPath()\n\n    const [promise, resolve, reject] = this.createOnStartPromise()\n    this._onStart = promise\n\n    this._diagnostics = undefined\n\n    // When we start make all buffer handlers pending so that they\n    // get added.\n    for (const [method, handler] of this._notificationHandlers) {\n      if (!this._pendingNotificationHandlers.has(method)) {\n        this._pendingNotificationHandlers.set(method, handler)","sourceCodeStart":974,"sourceCodeEnd":1010,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/language-client/client.ts#L974-L1010","documentation":"LanguageClient._start() throws this when the client's state is ClientState.Stopping — a stop is in flight — and a start is requested. A client mid-shutdown cannot be started; it must reach a fully stopped state first. This guards against interleaving async start/stop transitions.","triggerScenarios":"Calling client.start() while a previous client.stop() promise is still unresolved (server process still shutting down, dispose handlers running); rapid restart sequences (stop immediately followed by start without awaiting); :CocRestart racing with an in-flight start/stop.","commonSituations":"Autocommands (FocusGained/BufWritePost) triggering restarts while a stop is pending; watchers restarting servers on config change during shutdown; tests or scripts calling start/stop back-to-back without awaiting.","solutions":["Await the pending stop() promise before calling start(); retry start after it resolves.","Serialize lifecycle transitions through a queue/promise chain in extension code.","Prefer client.restart() over manual stop+start — it handles state transitions.","If state is wedged at Stopping, run :CocRestart or check for a hung server process (ps aux | grep <server>) blocking shutdown."],"exampleFix":"// before\nclient.stop()\nclient.start() // throws: currently stopping\n\n// after\nawait client.stop()\nawait client.start()","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"async function safeStart(client) {\n  for (let attempt = 0; attempt < 3; attempt++) {\n    try {\n      await client.start()\n      return\n    } catch (e) {\n      if (String(e).includes('currently stopping')) {\n        await new Promise(r => setTimeout(r, 300))\n        continue\n      }\n      throw e\n    }\n  }\n}","preventionTips":["Always await stop() before issuing start().","Prefer client.restart() over manual stop+start sequences.","Debounce restart triggers (config watchers, autocommands) to avoid overlapping transitions.","Avoid stop/start from concurrent autocmds without a promise chain."],"tags":["language-client","lifecycle","state-machine","lsp"],"backgroundTag":"client-state-stopping","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}