{"record":{"id":"44a1f89c8502e017","repo":"microsoft/typescript-go","slug":"language-server-is-not-running","errorCode":null,"errorMessage":"Language server is not running.","messagePattern":"Language server is not running\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"_extension/src/session.ts","lineNumber":69,"sourceCode":"    async restart(context: vscode.ExtensionContext): Promise<void> {\r\n        if (this.currentSession) {\r\n            this.outputChannel.appendLine(\"Restarting TypeScript language server...\");\r\n            await this.currentSession.stop();\r\n        }\r\n        this.currentSession = new Session(context, this.outputChannel, this.initializedEventEmitter, this.telemetryReporter, () => this.stop(), () => this.restart(context));\r\n        return this.currentSession.start(context);\r\n    }\r\n\r\n    async stop(): Promise<void> {\r\n        if (this.currentSession) {\r\n            await this.currentSession.stop();\r\n            this.currentSession = undefined;\r\n        }\r\n    }\r\n\r\n    async initializeAPIConnection(pipe?: string): Promise<string> {\r\n        if (!this.currentSession) {\r\n            throw new Error(vscode.l10n.t(\"Language server is not running.\"));\r\n        }\r\n        const result = await this.currentSession.client.initializeAPISession(pipe);\r\n        return result.pipe;\r\n    }\r\n\r\n    async dispose(): Promise<void> {\r\n        await this.currentSession?.dispose();\r\n        await Promise.all(this.disposables.map(d => d.dispose()));\r\n    }\r\n}\r\n\r\n/**\r\n * Session's lifetime is equal to that of its LanguageClient. The LanguageClient\r\n * can be restarted within the same Session only if the underlying exe path/version\r\n * has not changed. Otherwise, a new Session must be created. Since Session only\r\n * exists while the LSP server is running (or actively starting/restarting/stopping),\r\n * it also owns the commands and UI elements that should only be active while the\r\n * server is running.\r","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/_extension/src/session.ts#L51-L87","documentation":"Thrown by SessionManager.initializeAPIConnection(pipe?) when this.currentSession is undefined. A Session only exists while the TS7 language server is running (or starting); stop() sets currentSession to undefined. The method forwards to the session's client to create an API session over a named pipe, so it hard-fails when the server is down.","triggerScenarios":"Executing typescript.native-preview.initializeAPIConnection before the first Session.start() finished, after 'Disable TypeScript 7' (which calls stopSession and clears currentSession), after a session stop, or during the gap while restart() is replacing the session.","commonSituations":"Tooling that connects to the tsgo API pipe (API.fromLSPConnection) racing extension activation; initializing an API connection in a workspace where TS7 was disabled; retrying after the server crashed.","solutions":["Start or restart the server first (typescript.native-preview.restart), await it, then call initializeAPIConnection","Re-enable TypeScript 7 (js/ts.experimental.useTsgo = true) if it was disabled","Check the TypeScript output channel for why the session is not running and fix that","Catch the error and surface 'Language server is not running' as the extension's .ui variant does"],"exampleFix":"// before\nconst pipe = await vscode.commands.executeCommand('typescript.native-preview.initializeAPIConnection');\n\n// after - ensure a live session first, restart is idempotent\nawait vscode.commands.executeCommand('typescript.native-preview.restart');\nconst pipe = await vscode.commands.executeCommand('typescript.native-preview.initializeAPIConnection');","handlingStrategy":"validation","validationCode":"// Ensure a live session before asking for an API pipe; restart is idempotent\nawait vscode.commands.executeCommand('typescript.native-preview.restart');\nconst pipe: string = await vscode.commands.executeCommand('typescript.native-preview.initializeAPIConnection');","typeGuard":null,"tryCatchPattern":"try {\n    pipe = await sessionManager.initializeAPIConnection();\n} catch (e) {\n    if (e instanceof Error && e.message.includes('not running')) {\n        await sessionManager.restart(context); // bring the server up, then retry once\n        pipe = await sessionManager.initializeAPIConnection();\n    } else throw e;\n}","preventionTips":["Drive API-pipe setup from the same code path that starts the session, not independently","Re-enable TS7 (js/ts.experimental.useTsgo) before requesting API connections","Watch the serverRunning context to sequence connection setup after startup"],"tags":["vscode-extension","lifecycle","api-session","named-pipe"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}