microsoft/TypeScript · error · Error
Request: ${request.command} not allowed in LanguageServiceMo
Error message
Request: ${request.command} not allowed in LanguageServiceMode.PartialSemantic What it means
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.
Source
Thrown at src/server/session.ts:1084
allowLocalPluginLoads: opts.allowLocalPluginLoads,
typesMapLocation: opts.typesMapLocation,
serverMode: opts.serverMode,
session: this,
canUseWatchEvents: opts.canUseWatchEvents,
incrementalVerifier: opts.incrementalVerifier,
};
this.projectService = new ProjectService(settings);
this.projectService.setPerformanceEventHandler(this.performanceEventHandler.bind(this));
this.gcTimer = new GcTimer(this.host, /*delay*/ 7000, this.logger);
// Make sure to setup handlers to throw error for not allowed commands on syntax server
switch (this.projectService.serverMode) {
case LanguageServiceMode.Semantic:
break;
case LanguageServiceMode.PartialSemantic:
invalidPartialSemanticModeCommands.forEach(commandName =>
this.handlers.set(commandName, request => {
throw new Error(`Request: ${request.command} not allowed in LanguageServiceMode.PartialSemantic`);
})
);
break;
case LanguageServiceMode.Syntactic:
invalidSyntacticModeCommands.forEach(commandName =>
this.handlers.set(commandName, request => {
throw new Error(`Request: ${request.command} not allowed in LanguageServiceMode.Syntactic`);
})
);
break;
default:
Debug.assertNever(this.projectService.serverMode);
}
}
private sendRequestCompletedEvent(requestId: number, performanceData: PerformanceData | undefined): void {
this.event<protocol.RequestCompletedEventBody>(
{
View on GitHub (pinned to b465fdbfe1)
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.
Example fix
// before — server started in partial mode but client sends semantic cmd
spawn('tsserver', ['--serverMode', 'partialSemantic']);
client.send({ command: 'semanticDiagnosticsSync', arguments: { file: 'a.ts' } });
// throws: Request: semanticDiagnosticsSync not allowed in LanguageServiceMode.PartialSemantic
// after — use full semantic mode
spawn('tsserver', []); // default Semantic
client.send({ command: 'semanticDiagnosticsSync', arguments: { file: 'a.ts' } }); Defensive patterns
Strategy: validation
Validate before calling
// Block-listed commands in PartialSemantic mode (mirror session.ts:908).
const invalidPartialSemanticModeCommands: ReadonlySet<string> = new Set([
'openExternalProject','openExternalProjects','closeExternalProject','synchronizeProjectList',
'emitOutput','compileOnSaveAffectedFileList','compileOnSaveEmitFile','compilerOptionsDiagnosticsFull',
'encodedSemanticClassificationsFull','semanticDiagnosticsSync','suggestionDiagnosticsSync',
'geterrForProject','reload','reloadProjects','getCodefixes','getCodeFixesFull','getCombinedCodeFix',
'getCombinedCodeFixFull','applyCodeActionCommand','getSupportedCodeFixes','getApplicableRefactors',
'getMoveToRefactoringFileSuggestions','getEditsForRefactor','getEditsForRefactorFull',
'organizeImports','organizeImportsFull','getEditsForFileRename','getEditsForFileRenameFull',
'prepareCallHierarchy','provideCallHierarchyIncomingCalls','provideCallHierarchyOutgoingCalls',
'getPasteEdits','copilotRelated',
]);
function isAllowedInPartialSemantic(command: string): boolean {
return !invalidPartialSemanticModeCommands.has(command);
} Type guard
function isPartialSemanticAllowed(command: string, mode: string): boolean {
if (mode !== 'partialSemantic') return true;
return !invalidPartialSemanticModeCommands.has(command);
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Request: ${request.command} not allowed in LanguageServiceMo
- No Project.
- The project's language service is disabled.
- Project '${project.getProjectName()}' does not contain docum
- Invalid name for template cancellation pipe: it should have
AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12).
Data as JSON: /api/errors/22850bf29f1541d8.
Report an issue: GitHub.