microsoft / microsoft/TypeScript
RangeError - Maximum call stack size exceeded - in tsserver / vscode extension host - when providing type args to fn lambda
@weswigham arbeitet bereits daran.
Seit 05.2.2025.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
### 🔎 Search Terms
RangeError
Maximum call stack size exceeded
stack overflow
vscode
intellisense
autocomplete
suggestions
### 🕗 Version & Regression Information
This is the behaviour in every version I tried, and I reviewed the FAQ for entries about 'generic function arguments'.
I have tried this in `5.5.4` up to `next`.
### ⏯ Playground Link
https://github.com/cleric-sh/repro/tree/tsserver-RangeError-in-vscode
### 💻 Code
Can't reproduce this in TS Playground, unfortunately, as it occurs with multiple files.
The error occurs when built (compiled) artefacts from one workspace package are imported by another, consuming package. In this case, `consumer` -> `pkg`.
To see this error, the repo really needs to be viewed in VSCode.
In `consumer/index.ts`:
```ts
import { Container } from "pkg";
/**
* The error is also displayed if importing the .d.ts file directly.
*/
// import { Container } from "../pkg/dist/Container";
export class HomePage extends Container {
// Invoke intellisense completion / suggestions here
// Observe the error in Output > Extension Host
// Go to * Go to 'pkg/dist/Container.ts' to trigger the error.
}
```
In `pkg/dist/Container.d.ts`:
```ts
import type { TraverseArgs } from './traverse';
export declare class Container
{
/**
* This line (including generic arg for 'TraverseArgs') produces 'Maximum call stack size exceeded' in Extension Host.
* Go to 'consumer/index.ts' to trigger the error.
*/
$traverse(...args: [typeof TraverseArgs]): unknown
/**
* The same line without the generic arg for 'TraverseArgs' does not emit the same error.
*/
// $traverse(...args: [typeof TraverseArgs]): unknown
}
```
In `pkg/dist/traverse.d.ts`:
```ts
export declare const TraverseArgs: () => unknown
```
### 🙁 Actual behavior
#### Maximum call stack size exceeded error in `tsserver`
The code in this repository produces an error in `tsserver` in `vscode`'s Extension Host.
The `pkg` workspace represents a locally built package in a workspace that is referenced by `consumer`.
##### Steps to repro
1. `pnpm i`
1. Open the Output > Extension Host view
1. Go to `consumer/index.ts`
1. Trigger autocomplete / suggestions intellisense action inside the `HomePage` class, as per comments.
1. Observe the error in Output.
1. Go to `pkg/dist/Container.d.ts`
1. Comment out the `traverse` fn and uncomment the alternative.
1. Go to `consumer/index.ts` and trigger suggestions again.
1. Note that the suggestions are now working and the error is not emitted.
##### The blame
In this case, passing arguments to the lambda causes the error:
```ts
$traverse(...args: [typeof TraverseArgs]): unknown
//This arg --> ^
```
Whereas the following does not:
```ts
$traverse(...args: [typeof TraverseArgs]): unknown
```
##### The error
The error produced is:
```
Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
at String.replace ()
at Object.toFileNameLowerCase [as getCanonicalFileName] (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:3364:46)
at getCanonicalFileName (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:127619:17)
at toPath (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:8901:10)
at toPath3 (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:126111:12)
at getResolvedProjectReferenceToRedirect (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:127453:78)
at getRedirectReferenceForResolution (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:126074:22)
at getCompilerOptionsForFile (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:127520:20)
at Object.getDefaultResolutionModeForFile2 [as getDefaultResolutionModeForFile] (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:128547:62)
at resolveExternalModule (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:53540:151)
at resolveExternalModuleNameWorker (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:53517:61)
at resolveExternalModuleName (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:53514:12)
at getAlternativeContainingModules (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:53999:32)
at getWithAlternativeContainers (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:54064:58)
at getContainersOfSymbol (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:54031:14)
at getSymbolChain (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:56557:27)
at lookupSymbolChainWorker (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:56542:36)
at lookupSymbolChain (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:56536:14)
at symbolToTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:56710:21)
at serializeTypeName (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:57259:14)
at Object.serializeTypeName (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:54836:16)
at tryVisitTypeQuery (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136241:39)
at visitExistingNodeTreeSymbolsWorker (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136439:24)
at visitExistingNodeTreeSymbols (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136189:22)
at visitNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:93631:19)
at tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136179:25)
at Object.tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136171:14)
at createAnonymousTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55469:53)
at typeToTypeNodeWorker (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55291:16)
at typeToTypeNodeHelper (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55072:24)
at serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:57306:14)
at Object.serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:54794:16)
at visitExistingNodeTreeSymbols (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136194:27)
at visitNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:93631:19)
at tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136179:25)
at Object.tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136171:14)
at createAnonymousTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55469:53)
at typeToTypeNodeWorker (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55291:16)
at typeToTypeNodeHelper (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55072:24)
at serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:57306:14)
at Object.serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:54794:16)
at visitExistingNodeTreeSymbols (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136194:27)
at visitNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:93631:19)
at tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136179:25)
at Object.tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136171:14)
at createAnonymousTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55469:53)
at typeToTypeNodeWorker (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55291:16)
at typeToTypeNodeHelper (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55072:24)
at serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:57306:14)
at Object.serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:54794:16)
at visitExistingNodeTreeSymbols (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136194:27)
at visitNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:93631:19)
at tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136179:25)
at Object.tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136171:14)
at createAnonymousTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55469:53)
at typeToTypeNodeWorker (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55291:16)
at typeToTypeNodeHelper (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55072:24)
at serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:57306:14)
at Object.serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:54794:16)
at visitExistingNodeTreeSymbols (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136194:27)
at visitNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:93631:19)
at tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136179:25)
at Object.tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136171:14)
at createAnonymousTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55469:53)
at typeToTypeNodeWorker (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55291:16)
at typeToTypeNodeHelper (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55072:24)
at serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:57306:14)
at Object.serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:54794:16)
at visitExistingNodeTreeSymbols (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136194:27)
at visitNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:93631:19)
at tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136179:25)
at Object.tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136171:14)
at createAnonymousTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55469:53)
at typeToTypeNodeWorker (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55291:16)
at typeToTypeNodeHelper (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55072:24)
at serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:57306:14)
at Object.serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:54794:16)
at visitExistingNodeTreeSymbols (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136194:27)
at visitNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:93631:19)
at tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136179:25)
at Object.tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136171:14)
at createAnonymousTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55469:53)
at typeToTypeNodeWorker (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55291:16)
at typeToTypeNodeHelper (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55072:24)
at serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:57306:14)
at Object.serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:54794:16)
at visitExistingNodeTreeSymbols (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136194:27)
at visitNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:93631:19)
at tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136179:25)
at Object.tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136171:14)
at createAnonymousTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55469:53)
at typeToTypeNodeWorker (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55291:16)
at typeToTypeNodeHelper (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55072:24)
at serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:57306:14)
at Object.serializeExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:54794:16)
at visitExistingNodeTreeSymbols (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136194:27)
at visitNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:93631:19)
at tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136179:25)
at Object.tryReuseExistingTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:136171:14)
at createAnonymousTypeNode (/node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/typescript.js:55469:53)
at n.create (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:1:486366)
at y.dispatchResponse (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:1:480336)
at y.dispatchMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:1:479134)
at ChildProcess. (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:1:478627)
at ChildProcess.emit (node:events:518:28)
at emit (node:internal/child_process:950:14)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
2025-02-04 14:21:53.264 [error] [vscode.typescript-language-features] provider FAILED
```
### 🙂 Expected behavior
Suggestions to appear as expected, no error to be emitted.
### Additional information about the issue
This issue does not occur if `pkg` exports the `ts` files directly, instead of built `.d.ts` artefacts.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.