microsoft/TypeScript · error · Error

Request: ${request.command} not allowed in LanguageServiceMo

Error message

Request: ${request.command} not allowed in LanguageServiceMode.Syntactic

What it means

Thrown by Session (session.ts:1091) for commands in invalidSyntacticModeCommands when tsserver runs in LanguageServiceMode.Syntactic. Syntactic mode is even more restrictive than PartialSemantic: it layers every partial-semantic block on top of additional semantic commands (Definition, References, Rename, Quickinfo, Completions, SignatureHelp, DocumentHighlights, etc. — see session.ts:944-972).

Source

Thrown at src/server/session.ts:1091

        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>(
            {
                request_seq: requestId,
                performanceData: performanceData && toProtocolPerformanceData(performanceData),
            },
            "requestCompleted",
        );
    }

View on GitHub (pinned to b465fdbfe1)

Solutions

  1. Switch to full Semantic serverMode (`--serverMode semantic` or omit the flag) if the client needs definition/references/completions/diagnostics.
  2. Restrict the client to syntactic-only commands (e.g. encodedSyntacticClassifications, navTree, getOutliningSpans) while in Syntactic mode.
  3. Verify the command is not in invalidSyntacticModeCommands (session.ts:944) before dispatching.
  4. If the goal is lower memory, prefer PartialSemantic (which still allows some semantic work) over Syntactic.

Example fix

// before — syntactic server receiving a definition request
spawn('tsserver', ['--serverMode', 'syntactic']);
client.send({ command: 'definition', arguments: { file: 'a.ts', line: 1, offset: 1 } });
// throws: Request: definition not allowed in LanguageServiceMode.Syntactic

// after — start in semantic mode for definition support
spawn('tsserver', []); // default Semantic
client.send({ command: 'definition', arguments: { file: 'a.ts', line: 1, offset: 1 } });
Defensive patterns

Strategy: validation

Validate before calling

// Block-listed commands in Syntactic mode (mirror session.ts:944; superset of partial).
const invalidSyntacticModeCommands: ReadonlySet<string> = new Set([
  ...invalidPartialSemanticModeCommands,
  'definition','definitionFull','definitionAndBoundSpan','definitionAndBoundSpanFull',
  'typeDefinition','implementation','implementationFull','references','referencesFull',
  'rename','renameLocationsFull','renameInfoFull','quickinfo','quickinfoFull',
  'completionInfo','completions','completionsFull','completionDetails','completionDetailsFull',
  'signatureHelp','signatureHelpFull','navto','navtoFull','documentHighlights',
  'documentHighlightsFull','preparePasteEdits',
]);
function isAllowedInSyntactic(command: string, mode: string): boolean {
  if (mode !== 'syntactic') return true;
  return !invalidSyntacticModeCommands.has(command);
}

Type guard

function isSyntacticAllowed(command: string, mode: string): boolean {
  if (mode !== 'syntactic') return true;
  return !invalidSyntacticModeCommands.has(command);
}

Prevention

When it happens

Trigger: tsserver launched with `--serverMode syntactic` and the client issues any semantic or partial-semantic command. The handler for that command was overwritten at session init with a thunk that always throws this message.

Common situations: Pure syntax server (e.g. for fast highlighting in a low-resource editor) receiving completion/quick-info/diagnostics requests; a plugin that assumes full language service; misconfigured serverMode in the client spawn options.

Related errors


AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12). Data as JSON: /api/errors/391487f0c1730e55. Report an issue: GitHub.