{"record":{"id":"26c63779f4c7c5a8","repo":"can1357/oh-my-pi","slug":"lsp-configuration-was-superseded-during-initializa","errorCode":null,"errorMessage":"LSP configuration was superseded during initialization: ${config.command}","messagePattern":"LSP configuration was superseded during initialization: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/coding-agent/src/lsp/client.ts","lineNumber":1121,"sourceCode":"\t\t\t}\n\n\t\t\tclient.serverCapabilities = initResult.capabilities as LspClient[\"serverCapabilities\"];\n\n\t\t\t// Finish the initialize handshake before publishing the client as ready.\n\t\t\tawait sendNotification(client, \"initialized\", {}, signal);\n\t\t\tawait sendNotification(\n\t\t\t\tclient,\n\t\t\t\t\"workspace/didChangeConfiguration\",\n\t\t\t\t{ settings: config.settings ?? {} },\n\t\t\t\tsignal,\n\t\t\t);\n\n\t\t\tclient.status = \"ready\";\n\t\t\t// Publish only after init succeeds: pre-init clients are reachable\n\t\t\t// solely through clientLocks, so concurrent callers (warmup vs first\n\t\t\t// tool call) wait for init instead of using an unacknowledged client.\n\t\t\tif (invalidatedClientKeys.has(key)) {\n\t\t\t\tthrow new Error(`LSP configuration was superseded during initialization: ${config.command}`);\n\t\t\t}\n\t\t\tclients.set(key, client);\n\t\t\tinitFailures.delete(key);\n\t\t\treturn client;\n\t\t} catch (err) {\n\t\t\t// Clean up on initialization failure\n\t\t\tclient.status = \"error\";\n\t\t\tif (clients.get(key) === client) clients.delete(key);\n\t\t\tproc.kill();\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t// Negative-cache deterministic failures. Timeouts under a\n\t\t\t// caller-shortened deadline (warmup/writethrough) and caller-signal\n\t\t\t// aborts are transient — the server may simply be slow or the user may\n\t\t\t// have cancelled, so a later call with a fresh deadline should retry.\n\t\t\tif (!signal?.aborted && !(initTimeoutMs !== undefined && message.includes(\"timed out\"))) {\n\t\t\t\tinitFailures.set(key, { at: Date.now(), message });\n\t\t\t}\n\t\t\tthrow err;","sourceCodeStart":1103,"sourceCodeEnd":1139,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/lsp/client.ts#L1103-L1139","documentation":"Just before publishing a successfully initialized client into the shared client map, the code re-checks the invalidated set. If a config reload invalidated this key while initialization was running, the ready client is discarded and an error thrown — publishing it would expose a client whose config no longer matches user intent.","triggerScenarios":"Client initialization takes a while (slow server); during that window the user/config system triggers an LSP reload that invalidates the key; when init finishes, the check fires and the fully initialized client is thrown away.","commonSituations":"Editing LSP server settings while a slow-starting server (e.g. jdtls, rust-analyzer on a big project) initializes; config file watcher firing during startup.","solutions":["Retry the LSP operation — the retry creates a client from current config","Wait for config reloads to complete before triggering LSP-heavy operations","Avoid rapid successive config edits that repeatedly invalidate in-flight clients"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Avoid initiating LSP work while a config reload is pending\nif (configReloadPending) await configReloadFinished;","typeGuard":null,"tryCatchPattern":"try {\n  const client = await getConfigOrCreate(config, cwd);\n} catch (err) {\n  if (String(err.message).includes('superseded during initialization')) {\n    return getConfigOrCreate(config, cwd); // retry picks up new config\n  }\n  throw err;\n}","preventionTips":["Don't trigger LSP reloads while servers are initializing (debounce config watchers)","Retry 'superseded' errors once — the second attempt always uses fresh config","Batch config edits instead of saving repeatedly"],"tags":["lsp","race-condition","initialization"],"backgroundTag":"lsp-config-superseded-during-reload","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}