You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Parser: exponential time and memory on nested a < (b = β¦) (failed type argument speculation is retried)Β #64763
Parse time and memory grow about 3Γ with each nesting level. Numbers for tsc 7.0.2 (native); the file reports no errors:
n (bytes)
Parse time
Max RSS
6 (103)
0.01 s
0.11 GB
13 (173)
0.90 s
1.7 GB
14 (183)
2.8 s
4.8 GB
15 (193)
8.0 s
14.5 GB
typescript@next behaves the same. Malformed input grows even faster, about 5Γ per level. "a=b<c<(".repeat(11) is 77 bytes and takes 13.8 s and 21.6 GB.
A single small file can therefore make the compiler or the language server hang, and then run out of memory.
To be clear, I don't think people write such code by hand. Depth up to about 6 costs nothing measurable. I found this by fuzzing a tool built on a TS parser, not from a real codebase. It can still come from generated code, from code mid-edit in an editor, or from untrusted input to services that parse TypeScript.
π Expected behavior
Parse time and memory stay roughly proportional to the input size.
Activity
moznion commentedon Oct 13, 2026
Iβve already prepared a patch in main...moznion:TypeScript:fix/parser-type-arguments-retry, so Iβd be happy to submit a pull request to fix this issue.