microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
99.24k stars 12.31k forks source link

TS Server fatal error: Debug Failure. False expression. #48603

Open edgargressie opened 2 years ago

edgargressie commented 2 years ago

Issue Type: Bug

❗️❗️❗️ Please fill in the sections below to help us diagnose the issue ❗️❗️❗️

TypeScript Version: 4.6.3

Steps to reproduce crash

  1. Use search and compare tree with 200 files
  2. Compare files
  3. Open some files

TS Server Log ❗️Server logging disabled. To help us fix crashes like this, please enable logging by setting:

"typescript.tsserver.log": "verbose"

After enabling this setting, future crash reports will include the server log.

TS Server Error Stack Server: semantic

Error: Debug Failure. False expression.
    at _loop_2 (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:169026:34)
    at ProjectService.assignOrphanScriptInfoToInferredProject (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:169034:25)
    at ProjectService.assignProjectToOpenedScriptInfo (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:170700:26)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:170974:97
    at Object.flatMap (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:508:25)
    at ProjectService.applyChangesInOpenFiles (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:170974:41)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:172133:46)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:174069:88
    at IpcIOSession.Session.executeWithRequestId (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:174060:28)
    at IpcIOSession.Session.executeCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:174069:33)
    at IpcIOSession.Session.onMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:174095:35)
    at process.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:176730:31)
    at process.emit (node:events:390:28)
    at emit (node:internal/child_process:917:12)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)

VS Code version: Code 1.66.0 (e18005f0f1b33c29e81d732535d8c0e47cafb0b5, 2022-03-30T05:49:37.118Z) OS version: Darwin arm64 21.4.0 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Apple M1 Pro (10 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|3, 3, 3| |Memory (System)|32.00GB (4.59GB free)| |Process Argv|--crash-reporter-id c0903e5b-9907-4c1a-8c69-fa0bfc3f4b9b| |Screen Reader|no| |VM|0%|
Extensions (44) Extension|Author (truncated)|Version ---|---|--- Bookmarks|ale|13.2.4 cucumberautocomplete|ale|2.15.2 ng-template|Ang|13.3.0 atlascode|atl|2.10.11 vscode-eslint|dba|2.2.2 gitlens|eam|12.0.5 vscode-html-css|ecm|1.11.0 EditorConfig|Edi|0.16.4 vscode-npm-script|eg2|0.3.24 prettier-vscode|esb|9.5.0 php-intellisense|fel|2.3.14 vscode-jest-runner|fir|0.4.48 auto-rename-tag|for|0.1.10 remotehub|Git|0.30.0 todo-tree|Gru|0.0.215 name-that-color|gui|0.1.6 batch-rename-extension|Jan|0.0.5 vscode-peacock|joh|4.0.1 vscode-colorize|kam|0.11.1 vscode-gutter-preview|kis|0.30.0 HTMLHint|mka|0.10.0 vscode-scss|mrm|0.10.0 remote-repositories|ms-|0.4.0 vscode-typescript-tslint-plugin|ms-|1.3.4 vsliveshare|ms-|1.0.5449 vsliveshare-audio|ms-|0.1.91 vsliveshare-pack|ms-|0.4.0 angular-console|nrw|17.15.0 vscode-nunjucks-formatter|oki|0.1.3 vscode-yaml|red|1.6.0 nunjucks|ron|0.3.1 vs-code-prettier-eslint|rve|3.1.0 angular-follow-selector|san|1.2.0 markdown-preview-enhanced|shd|0.6.2 sonarlint-vscode|Son|3.4.0 autoimport|ste|1.5.4 code-spell-checker|str|2.1.11 code-spell-checker-dutch|str|0.3.0 tabnine-vscode|Tab|3.5.42 highlight-matching-tag|vin|0.10.1 vscodeintellicode|Vis|1.2.18 quokka-vscode|Wal|1.0.455 twig|wha|1.0.2 html-css-class-completion|Zig|1.20.0
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythonvspyl392:30443607 pythontb:30283811 pythonvspyt551:30345470 pythonptprofiler:30281270 vshan820:30294714 vstes263cf:30335440 pythondataviewer:30285071 vscod805:30301674 pythonvspyt200:30340761 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593:30376534 vsc1dst:30438360 pythonvs932:30410667 wslgetstarted:30449410 pythonvsnew555:30457759 vscscmwlcmt:30465135 cppdebug:30466689 pynewfile477:30463512 ```
mjbvz commented 2 years ago

Thanks for the report

What does search and compare tree with 200 files mean? Is this through an extension? Or is it some built-in functionality of VS Code?

edgargressie commented 2 years ago

Sorry for the lack of clarity. I was using the 'Search & compare' functionality in the 'Source control' section of the sidebar.

I think I found the problem, I was experimenting with 'complex' Typescript template literal strings for date formats in a large monorepo. I think that was too much for the internal compiler. I reverted the code and now everything works fine again. I hope it will work after upgrading TypeScript and our codebase to the latest version.

mjbvz commented 2 years ago

Can you share the type that was causing issues?

edgargressie commented 2 years ago
type TOneToNine = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
type TZeroToNine = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;

export type TYear = `${19 | 20}${TZeroToNine}${TZeroToNine}`;
type TMonth = `0${TOneToNine}` | `1${0 | 1 | 2}`;
type TDay = `0${TOneToNine}` | `${1 | 2}${TZeroToNine}` | `3${0 | 1}`;

export type TTime = `${number}:${number}`;
type TSeconds = number;

export type TApiDate = `${TYear}-${TMonth}-${TDay}`;
export type TApiDateTime = `${TApiDate}T${TTime}:${TSeconds}Z`;

export type TClientDate = `${TDay}-${TMonth}-${TYear}`;
export type TClientDateTime = `${TClientDate} ${TTime}`;

I was mainly using TApiDate and TApiDateTime. It was used around 350 times in 100 different files.

mjbvz commented 2 years ago

Thanks. Moving upstream so the TS team can investigate the perf issue

edgargressie commented 2 years ago

Thanks to you too Matt!

Op 7 apr. 2022 om 23:06 heeft Matt Bierner @.***> het volgende geschreven:

 Thanks. Moving upstream so the TS team can investigate the perf issue

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

RyanCavanaugh commented 2 years ago

That's a weird type indeed 😂 but the call stack actually doesn't seem related to that - this is basically in the code that takes the set of open files and projects and determines which file belongs to which project. If you can find a way to reproduce that reliably, we'd want to fix it.

edgargressie commented 2 years ago

Hehe, I know 😆. But I really like the new possibilities! I'll enable the more complex types in a few weeks and will let you know if I have more info.

edgargressie commented 1 year ago

After upgrading to TypeScript 4.7.4 and Angular 14.0.5, I get similar issues. The compiler just hangs after saving the TypeScript file. Maybe it is an Angular or Webpack issue, I don't know and can't provide more information other than the previous types. Sorry! 😔