{"record":{"id":"22850bf29f1541d8","repo":"microsoft/TypeScript","slug":"request-request-command-not-allowed-in-languag","errorCode":null,"errorMessage":"Request: ${request.command} not allowed in LanguageServiceMode.PartialSemantic","messagePattern":"Request: (.+?) not allowed in LanguageServiceMode\\.PartialSemantic","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/server/session.ts","lineNumber":1084,"sourceCode":"            allowLocalPluginLoads: opts.allowLocalPluginLoads,\r\n            typesMapLocation: opts.typesMapLocation,\r\n            serverMode: opts.serverMode,\r\n            session: this,\r\n            canUseWatchEvents: opts.canUseWatchEvents,\r\n            incrementalVerifier: opts.incrementalVerifier,\r\n        };\r\n        this.projectService = new ProjectService(settings);\r\n        this.projectService.setPerformanceEventHandler(this.performanceEventHandler.bind(this));\r\n        this.gcTimer = new GcTimer(this.host, /*delay*/ 7000, this.logger);\r\n\r\n        // Make sure to setup handlers to throw error for not allowed commands on syntax server\r\n        switch (this.projectService.serverMode) {\r\n            case LanguageServiceMode.Semantic:\r\n                break;\r\n            case LanguageServiceMode.PartialSemantic:\r\n                invalidPartialSemanticModeCommands.forEach(commandName =>\r\n                    this.handlers.set(commandName, request => {\r\n                        throw new Error(`Request: ${request.command} not allowed in LanguageServiceMode.PartialSemantic`);\r\n                    })\r\n                );\r\n                break;\r\n            case LanguageServiceMode.Syntactic:\r\n                invalidSyntacticModeCommands.forEach(commandName =>\r\n                    this.handlers.set(commandName, request => {\r\n                        throw new Error(`Request: ${request.command} not allowed in LanguageServiceMode.Syntactic`);\r\n                    })\r\n                );\r\n                break;\r\n            default:\r\n                Debug.assertNever(this.projectService.serverMode);\r\n        }\r\n    }\r\n\r\n    private sendRequestCompletedEvent(requestId: number, performanceData: PerformanceData | undefined): void {\r\n        this.event<protocol.RequestCompletedEventBody>(\r\n            {\r","sourceCodeStart":1066,"sourceCodeEnd":1102,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/server/session.ts#L1066-L1102","documentation":"Thrown by Session (session.ts:1084) for commands listed in invalidPartialSemanticModeCommands when tsserver is started in LanguageServiceMode.PartialSemantic. In that mode the server runs as a lightweight syntax+partial-semantic server and refuses heavy semantic operations; the throw is wired into the handler map at session construction so the request never reaches the language service.","triggerScenarios":"tsserver is launched with `--serverMode partialSemantic` (or the equivalent configuration) and a client sends one of the blocked commands — e.g. SemanticDiagnosticsSync, GetCodeFixes, OrganizeImports, GetEditsForRefactor, ProvideCallHierarchyIncomingCalls, Reload, EmitOutput (see the list at session.ts:908-942).","commonSituations":"An editor/IDE starts tsserver in partial-semantic mode to save memory and then issues a semantic request (go-to-def refactor, semantic diagnostics); a CI tool sends the same request payload regardless of server mode; mismatch between client expectations and the configured serverMode.","solutions":["Start tsserver without `--serverMode partialSemantic` (default Semantic mode) when the client needs full language-service features.","On the client, gate blocked commands on the negotiated serverMode and degrade gracefully (e.g. skip semantic diagnostics) when running partial-semantic.","If partial mode was chosen for memory, raise `maxTsServerMemory`/resources and run full Semantic instead.","Cross-check the requested command against invalidPartialSemanticModeCommands (session.ts:908) before sending."],"exampleFix":"// before — server started in partial mode but client sends semantic cmd\nspawn('tsserver', ['--serverMode', 'partialSemantic']);\nclient.send({ command: 'semanticDiagnosticsSync', arguments: { file: 'a.ts' } });\n// throws: Request: semanticDiagnosticsSync not allowed in LanguageServiceMode.PartialSemantic\n\n// after — use full semantic mode\nspawn('tsserver', []); // default Semantic\nclient.send({ command: 'semanticDiagnosticsSync', arguments: { file: 'a.ts' } });","handlingStrategy":"validation","validationCode":"// Block-listed commands in PartialSemantic mode (mirror session.ts:908).\nconst invalidPartialSemanticModeCommands: ReadonlySet<string> = new Set([\n  'openExternalProject','openExternalProjects','closeExternalProject','synchronizeProjectList',\n  'emitOutput','compileOnSaveAffectedFileList','compileOnSaveEmitFile','compilerOptionsDiagnosticsFull',\n  'encodedSemanticClassificationsFull','semanticDiagnosticsSync','suggestionDiagnosticsSync',\n  'geterrForProject','reload','reloadProjects','getCodefixes','getCodeFixesFull','getCombinedCodeFix',\n  'getCombinedCodeFixFull','applyCodeActionCommand','getSupportedCodeFixes','getApplicableRefactors',\n  'getMoveToRefactoringFileSuggestions','getEditsForRefactor','getEditsForRefactorFull',\n  'organizeImports','organizeImportsFull','getEditsForFileRename','getEditsForFileRenameFull',\n  'prepareCallHierarchy','provideCallHierarchyIncomingCalls','provideCallHierarchyOutgoingCalls',\n  'getPasteEdits','copilotRelated',\n]);\nfunction isAllowedInPartialSemantic(command: string): boolean {\n  return !invalidPartialSemanticModeCommands.has(command);\n}","typeGuard":"function isPartialSemanticAllowed(command: string, mode: string): boolean {\n  if (mode !== 'partialSemantic') return true;\n  return !invalidPartialSemanticModeCommands.has(command);\n}","tryCatchPattern":null,"preventionTips":["Negotiate serverMode up front and only send commands the mode allows.","Start tsserver in default Semantic mode when full features are needed.","Surface 'request not allowed in this mode' as a soft degradation in the client UI."],"tags":["server","tsserver","server-mode","protocol"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}