Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript slow project load times for large projects on MacOS #60832

Open
mjames-c opened this issue Dec 20, 2024 · 3 comments
Open

TypeScript slow project load times for large projects on MacOS #60832

mjames-c opened this issue Dec 20, 2024 · 3 comments

Comments

@mjames-c
Copy link

mjames-c commented Dec 20, 2024

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: v1.96.2
  • OS Version: MacOS
  • TypeScript: v5.7.2 (workspace version)
  • Node.JS: v20.18.0

Steps to Reproduce:

  1. Add the following to .vscode/settings.json
  "typescript.tsserver.log": "verbose",
  "files.watcherExclude": {
    "**/node_modules": true
  },

This causes:

2024-12-20 13:49:42.785 [info] <syntax> Falling back to legacy node.js based file watching because of user settings.
  1. Open a TS source file belonging to a large TS project with many project references in VSCode running on MacOS. For example, our project references a total of 25k+ files (transitively through project references):
Info 57414[13:12:03.001] Project '.../web/src/pages/editor/tsconfig.json' (Configured)
Info 57414[13:12:03.001] 	Files (26167)
  1. Notice that the tsserver logs are littered with the following log lines:
Info 57094[13:34:37.437] DirectoryWatcher:: Triggered with .../web/src/pages/editor :: WatchInfo: .../web/src/pages/editor 1 {"watchFile":2,"watchDirectory":2,"excludeDirectories":["/Users/mjames/work/canva/web/**/node_modules",".../web/**/target",".../web/**/bazel-bin",".../web/**/bazel-out",".../web/**/bazel-canva"]} Config: /Users/mjames/work/<redacted>/tsconfig.json WatchType: Wild card directory
Info 57095[13:34:37.437] Invoking sourceFileChange on .../web/src/pages/editor/editor_bootstrap_proto.ts:: 1
Info 57096[13:34:37.438] Scheduled: .../web/src/pages/editor/tsconfig.json
Info 57097[13:34:37.438] Scheduled: *ensureProjectForOpenFiles*
Info 57098[13:34:37.438] Invoking sourceFileChange on .../web/src/pages/<redacted>:: 1
Info 57099[13:34:37.438] Scheduled: .../web/src/pages/editor/tsconfig.json, Cancelled earlier one
Info 57100[13:34:37.438] Scheduled: *ensureProjectForOpenFiles*, Cancelled earlier one
Info 57101[13:34:37.438] Invoking sourceFileChange on .../web/src/pages/editor/<redacted>:: 1
Info 57102[13:34:37.438] Scheduled: .../web/src/pages/editor/tsconfig.json, Cancelled earlier one
Info 57103[13:34:37.438] Scheduled: *ensureProjectForOpenFiles*, Cancelled earlier one
Info 57104[13:34:37.438] Invoking sourceFileChange on .../web/src/pages/editor/<redacted>:: 1
Info 57105[13:34:37.438] Scheduled: .../web/src/pages/editor/tsconfig.json, Cancelled earlier one
Info 57106[13:34:37.442] Scheduled: *ensureProjectForOpenFiles*, Cancelled earlier one
Info 57107[13:34:37.442] Invoking sourceFileChange on .../web/src/pages/editor/<redacted>:: 1
Info 57108[13:34:37.442] Scheduled: .../web/src/pages/editor/tsconfig.json, Cancelled earlier one
Info 57109[13:34:37.442] Scheduled: *ensureProjectForOpenFiles*, Cancelled earlier one
Info 57110[13:34:37.442] Invoking sourceFileChange on .../web/src/pages/editor/<redacted>:: 1
Info 57111[13:34:37.443] Scheduled: .../web/src/pages/editor/tsconfig.json, Cancelled earlier one
Info 57112[13:34:37.443] Scheduled: *ensureProjectForOpenFiles*, Cancelled earlier one
Info 57113[13:34:37.443] Invoking sourceFileChange on .../web/src/pages/editor/editing/<redacted>:: 1
Info 57114[13:34:37.443] Scheduled: .../web/src/pages/editor/tsconfig.json, Cancelled earlier one
Info 57115[13:34:37.443] Scheduled: *ensureProjectForOpenFiles*, Cancelled earlier one
Info 57116[13:34:37.443] Invoking sourceFileChange on .../web/src/pages/editor/<redacted>:: 1
Info 57117[13:34:37.443] Scheduled: .../web/src/pages/editor/tsconfig.json, Cancelled earlier one
Info 57118[13:34:37.443] Scheduled: *ensureProjectForOpenFiles*, Cancelled earlier one
Info 57119[13:34:37.443] Invoking sourceFileChange on .../web/src/pages/editor/<redacted>:: 1
Info 57120[13:34:37.443] Scheduled: .../web/src/pages/editor/tsconfig.json, Cancelled earlier one
Info 57121[13:34:37.443] Scheduled: *ensureProjectForOpenFiles*, Cancelled earlier one
Info 57122[13:34:37.443] Invoking sourceFileChange on .../web/src/pages/editor/<redacted>:: 1
Info 57123[13:34:37.443] Scheduled: .../web/src/pages/editor/tsconfig.json, Cancelled earlier
...

The strange thing is that this is NOT a problem with .vscode-server running on Linux.

None of the 20k+ Invoking sourceFileChange on... log lines appear in the tsserver logs when running in our Linux based remote dev envs and the load time for this project is ~52s vs 3m45s!

Interestingly the problem also does NOT occur on MacOS when tsserver reuses VSCode's file watcher (i.e. the node_modules excludes aren't in the files.watcherExclude hash)

Copy link

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.96.2. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@mjames-c
Copy link
Author

mjames-c commented Dec 20, 2024

After looking into this more deeply this may actually be a problem with either TypeScript or Node.JS's file watcher. The tsserver logs seem to indicate that it is marking every single source file the project contains or depends on as changed:

Info 64556[10:03:19.662] Invoking sourceFileChange on /web/src/<redacted>:: 1

@mjbvz mjbvz transferred this issue from microsoft/vscode Dec 20, 2024
@mjbvz mjbvz removed their assignment Dec 20, 2024
@mjames-c
Copy link
Author

mjames-c commented Dec 23, 2024

Another data point... so far i've only seen the bug present in projects which depend upon >18k TS files. For example, one of our projects has ~14.6k TS files it depends upon and there are NOT any phantom file watch events.

I have also confirmed that this bug occurs in IntelliJ as well so it's not limited to VSCode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants