Repository: TypeScript
Issue: TS Server fatal error:  Cannot read property 'forEach' of undefined
Labels: Bug,Help Wanted


Issue Type: <b>Bug</b>

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

**TypeScript Version:** 4.3.0-dev.20210427

**Steps to reproduce crash**
1.
2.
3.

**TS Server Log**
❗️Server logging disabled. To help us fix crashes like this, please enable logging by setting:
```json
"typescript.tsserver.log": "verbose"
```
After enabling this setting, future crash reports will include the server log.

**TS Server Error Stack**
Server: `diagnostics`
```
TypeError: Cannot read property 'forEach' of undefined
    at Object.clearMap (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:18596:13)
    at ProjectService.stopWatchingWildCards (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:160829:20)
    at ConfiguredProject.releaseParsedConfig (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:158941:37)
    at /Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:159045:34
    at Map.forEach (<anonymous>)
    at ConfiguredProject.close (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:159044:66)
    at ProjectService.removeProject (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:160098:25)
    at /Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:161920:86
    at Map.forEach (<anonymous>)
    at ProjectService.removeOrphanConfiguredProjects (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:161920:44)
    at ProjectService.cleanupAfterOpeningFile (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:161864:22)
    at ProjectService.applyChangesInOpenFiles (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:162068:26)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:163115:46)
    at /Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:165032:88
    at IOSession.Session.executeWithRequestId (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:165023:28)
    at IOSession.Session.executeCommand (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:165032:33)
    at IOSession.Session.onMessage (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:165058:35)
    at Interface.<anonymous> (/Users/yhay81/.vscode/extensions/ms-vscode.vscode-typescript-next-4.3.20210427/node_modules/typescript/lib/tsserver.js:167660:31)
    at Interface.emit (events.js:315:20)
    at Interface._onLine (readline.js:329:10)
    at Interface._normalWrite (readline.js:474:12)
    at Socket.ondata (readline.js:186:10)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at Socket.Readable.push (_stream_readable.js:212:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)
```

VS Code version: Code 1.55.2 (3c4e3df9e89829dce27b7b5c24508306b151f30d, 2021-04-13T09:36:32.643Z)
OS version: Darwin x64 20.4.0

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz (12 x 3200)|
|GPU Status|2d_canvas: enabled<br>gpu_compositing: enabled<br>metal: disabled_off<br>multiple_raster_threads: enabled_on<br>oop_rasterization: enabled<br>opengl: enabled_on<br>protected_video_decode: unavailable_off<br>rasterization: enabled<br>skia_renderer: disabled_off_ok<br>video_decode: enabled<br>webgl: enabled<br>webgl2: enabled|
|Load (avg)|3, 9, 9|
|Memory (System)|64.00GB (18.46GB free)|
|Process Argv|--crash-reporter-id 66adc50f-0bab-4143-9b0b-8234cdd95c7d|
|Screen Reader|no|
|VM|0%|
</details><details><summary>Extensions (100)</summary>

Extension|Author (truncated)|Version
---|---|---
better-comments|aar|2.1.0
vscode-sqlite|ale|0.12.0
aws-toolkit-vscode|ama|1.24.0
vscode-color|ans|0.4.5
vscode-zipfs|arc|2.3.0
swagger-viewer|Arj|3.0.1
cform|aws|0.0.24
vscode-database|baj|2.2.3
vscode-django|bat|1.6.0
color-info|bie|0.6.0
vscode-tailwindcss|bra|0.5.10
turbo-console-log|Cha|2.1.6
npm-intellisense|chr|1.3.1
path-intellisense|chr|2.3.0
gitignore|cod|0.6.0
bracket-pair-colorizer-2|Coe|0.2.0
vscode-markdownlint|Dav|0.40.4
vscode-eslint|dba|2.1.20
vscode-dash|dee|2.4.0
githistory|don|0.6.16
xml|Dot|2.5.1
gitlens|eam|11.4.1
vscode-html-css|ecm|1.10.2
EditorConfig|Edi|0.16.4
vscode-npm-script|eg2|0.3.21
LogFileHighlighter|emi|2.11.0
vscode-great-icons|emm|2.1.73
json-tools|eri|1.0.2
prettier-vscode|esb|6.3.2
vscode-firefox-debug|fir|2.9.4
vscode-monorepo-workspace|fol|1.3.1
docker-explorer|for|0.1.7
vscode-mysql|for|0.4.0
vscode-yarn|gam|1.7.1
vscode-pull-request-github|Git|0.25.1
gc-excelviewer|Gra|3.0.41
docker-linter|hen|0.5.0
githd|hui|2.2.4
rest-client|hum|0.24.5
output-colorizer|IBM|0.1.2
css-to-jss|inf|1.0.6
mysql-syntax|jak|1.3.1
search-node-modules|jas|1.3.0
plantuml|jeb|2.14.5
svg|joc|1.4.5
docthis|joe|0.7.1
vscode-peacock|joh|3.9.1
vscode-styled-components|jpo|1.5.1
google-search|kam|0.0.1
chat|kar|0.35.0
vscode-gutter-preview|kis|0.27.1
node-module-intellisense|lei|1.5.0
restructuredtext|lex|149.0.0
yarn-lock-syntax|mar|0.1.3
rainbow-csv|mec|1.8.1
git-graph|mhu|1.30.0
dotenv|mik|1.0.1
vscode-filesize|mkx|3.1.0
vscode-autoprefixer|mrm|3.0.1
vscode-docker|ms-|1.12.1
vscode-postgresql|ms-|0.3.0
python|ms-|2021.5.790594320-dev
vscode-pylance|ms-|2021.4.3-pre.1
jupyter|ms-|2021.5.745244803
remote-containers|ms-|0.166.1
remote-ssh|ms-|0.65.4
remote-ssh-edit|ms-|0.65.4
remote-wsl|ms-|0.54.6
vscode-remote-extensionpack|ms-|0.20.0
vscode-typescript-next|ms-|4.3.20210427
vsliveshare|ms-|1.0.4131
vsliveshare-audio|ms-|0.1.91
debugger-for-chrome|msj|4.12.12
sqltools|mtx|0.23.0
color-highlight|nau|2.3.0
indent-rainbow|ode|7.5.0
vscode-versionlens|pfl|1.0.9
vscode-css-peek|pra|4.1.3
total-lines|pra|0.0.1
quicktype|qui|12.0.46
typescript-hero|rbb|3.0.0
vscode-yaml|red|0.18.0
LiveServer|rit|5.6.1
partial-diff|ryu|1.4.3
indenticator|Sir|0.7.0
code-spell-checker|str|1.10.2
vscode-stylelint|sty|0.86.0
language-stylus|sys|1.11.0
open-in-browser|tec|2.0.0
vscode-make|tec|1.0.2
pdf|tom|1.1.0
sort-lines|Tyr|1.9.0
vscodeintellicode|Vis|1.2.12
vscode-icons|vsc|11.4.0
gitblame|wad|6.0.2
vscode-wakatime|Wak|5.0.1
quokka-vscode|Wal|1.0.360
vscode-todo-highlight|way|1.0.4
jinja|who|0.0.8
html-css-class-completion|Zig|1.20.0


</details><details>
<summary>A/B Experiments</summary>

```
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
pythonvspyt602cf:30294773
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstry244:30276681
pythonvsnew554cf:30291488
pythontb:30283811
vspre833:30267464
pythonptprofiler:30281270
vshan820:30294714
pythondataviewer:30285071
vscus158cf:30286554
vscgsv2:30294352

```

</details>

<!-- generated by issue reporter -->