Skip to content

Update imports takes too long to show on large projects (up to 2 minutes) #41508

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

Closed
OliverJAsh opened this issue Nov 12, 2020 · 4 comments
Closed
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status. Needs More Info The issue still hasn't been fully clarified

Comments

@OliverJAsh
Copy link
Contributor

OliverJAsh commented Nov 12, 2020

TypeScript Version: 4.0.2

Search Terms: rename move file update imports

Code

Unfortunately I cannot provide a reduced test case as I can only reproduce this on our very large project, but I can provide the following:

  • screen recording
  • tsserver verbose.log
  • access to the project along with steps to reproduce:
    1. Clone and checkout https://github.com/unsplash/unsplash-web/tree/typescript-rename-issue, branch typescript-rename-issue. This is a private repository but I believe some members of the TS team already have access from debugging previous issues. If you don't have access, please send me your email address so I can provide access (TS team members only).
    2. Run yarn to install TS
    3. Open VS Code
    4. Select workspace TS version
    5. Open app/components/VisualSearchFormPopover/VisualSearchFormPopover.tsx
    6. Rename this file

I had a quick look through the TSServer log to see if anything obvious stood out. It looks like getEditsForFileRename is taking too long:

Info 2081 [11:33:26.251] FileWatcher:: Added:: WatchInfo: /Users/oliverash/Development/unsplash-web/node_modules/@sentry/utils/dist/instrument.d.ts.map 2000 undefined Project:  WatchType: Missing source map file
Info 2082 [11:33:26.252] FileWatcher:: Added:: WatchInfo: /Users/oliverash/Development/unsplash-web/node_modules/@sentry/utils/dist/dsn.d.ts.map 2000 undefined Project:  WatchType: Missing source map file
Info 2083 [11:33:26.252] FileWatcher:: Added:: WatchInfo: /Users/oliverash/Development/unsplash-web/node_modules/@sentry/utils/dist/index.d.ts.map 2000 undefined Project:  WatchType: Missing source map file
Perf 2084 [11:34:43.151] 45::getEditsForFileRename: elapsed time (in milliseconds) 92021.5584
Info 2085 [11:34:43.152] response:
    {"seq":0,"type":"response","command":"getEditsForFileRename","request_seq":45,"success":true,"performanceData":{"updateGraphDurationMs":5089},"body":[{"fileName":"/Users/oliverash/Development/unsplash-web/app/components/VisualSearchFormPopover/index.ts","textChanges":[{"start":{"line":1,"offset":16},"end":{"line":1,"offset":41},"newText":"./VisualSearchFormPopover2"}]}]}

Potentially related: this project uses project references and the root tsconfig.json is a "solution" style project. I tried disabling project references but the problem remained.

Expected behavior:

Actual behavior:

Playground Link:

Related Issues:

I've ran into this before but it was fixed. For some reason, it seems to be broken again. Whether that's due to a change in TS or a change in our codebase, I do not know.

Related:

@garvik
Copy link

garvik commented Nov 12, 2020

I'm getting the same issue on my project (also a quite large, private repo) using TS version 4.0.5. The issue goes away after switching to typescript@next (4.2.0-dev.20201109)

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Nov 13, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.2.0 milestone Nov 13, 2020
@sheetalkamat
Copy link
Member

@OliverJAsh looking at the log, it looks like half of the time is spent trying to load projects.
Your project requires node 12 but i am on node 14 without being able to downgrade right away.
Can you try what happens on second rename request after first getEditsForFileRename is completed (loading all the projects)
Also does this repro with typescript@next ? @andrewbranch made some changes in auto import with symlinks etc so that might help.
Please post updated server log if that still is the issue.
Thanks

@sheetalkamat sheetalkamat added the Needs More Info The issue still hasn't been fully clarified label Jan 29, 2021
@sheetalkamat
Copy link
Member

Actually i was able to verify that this does not repro if this is not first project load any more with typescript@next

Info 2008 [16:47:16.397] request:
    {"seq":51,"type":"request","command":"getEditsForFileRename","arguments":{"oldFilePath":"c:/temp/unsplash-web/app/components/VisualSearchFormPopover/file2.tsx","newFilePath":"c:/temp/unsplash-web/app/components/VisualSearchFormPopover/VisualSearchFormPopover.tsx"}}
Perf 2009 [16:47:16.970] 51::getEditsForFileRename: elapsed time (in milliseconds) 573.1634

Please open again if this repros with nightly

@OliverJAsh
Copy link
Contributor Author

Tested with 4.1.2 and 4.2.0-dev.20210129 and it's significantly faster. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status. Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

5 participants