-
-
Notifications
You must be signed in to change notification settings - Fork 458
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
Very long startup activation time #1143
Comments
This causes all sorts of problems. Most prominently, git will only be available after prettier has finished. I think this bugreport is related: microsoft/vscode#87102 |
Interesting, I haven't seen that before and our telemetry does not seem to indicate that this is common. Can you tell me, are you opening a workspace with lots of different projects. One thing the extension does have to do is activate for every workspace. It's possible that could be the issue. I have been considering moving the activation to be out of band as we don't technically need to activate anything until you open a file in a workspace, but that will be a fairly large refactor. If possible, could you provide a sample github repo that reproduces the issue? I will hop on my windows computer and try to verify. |
If I start VS Code without a folder (new window) it activates normally. I have tested it with a brand new vs code (insiders) installation, still the same. I am in a corporate environment with multiple slow network drives attached (the working directory and vscode are on my internal drives, though). I'll try to gather some more data, so I can narrow it down. |
My Startup Performance output looks like this: Extension Activation Stats
|
@divslinger I'm having the exact same issues. It all started this week. My environment sounds about the same as yours. I've tried multiple git repos. When I disconnect from the network, prettier extension seems to start up extremely fast. E: That 192s seems weirdly accurate. I just timed the start up and got 195s. Is this used as timeout value somewhere? |
Can confirm. Disconnecting from the network fixes it. |
Downgrading VS Code to 1.40.2 doesn't solve the issue. |
Interesting. It seems there are some VS Code issues that may be related (see: microsoft/vscode#86772). I can't think of anything that would have changed on the extension side that would have caused this. I'll do some digging though and see what i can find. |
I'm also getting a similar issue. I initially thought it was associated with the latest push of VScode version, but through disabling extensions found this tread and Prettier taking a long time to load. Commenting here to get latched to this thread. |
Has anyone tried to install an older version of the prettier extension? I'd be curious to understand if this was actually something introduced recently. I don't see any changes that seem related, but you never know. If possible try installing older versions to see if any of them make the problem go away and let me know which fixes it. I wasn't able to repro on my windows laptop so any additional info would be helpful. |
I tested older versions of prettier extension. No changes there. I don't think this is an issue on prettier extension itself. I spotted a new error message from VS Codes ESLint plugin. I think it also appeared on prettier's logs at one point. Immediately after this error shows up, prettier and eslint start working.
That path to Code.exe is correct. |
Found a solution/work-around. Set environment variable on windows: Prettier extension loads up in 5-10s now. Related issues where fix was found: |
Can confirm, this works! Great find! |
From @AriPerkkio related issues, seems we could disable it when running the commands. This is the command run by this extension. |
Removed the environment variable and ran script below. Note that this issue only exists when running npm using child_process. Npm on terminal is fine. I copied this script from those node issues I linked earlier. const { execFile } = require('child_process');
const precise = require('precise');
const timer = precise();
timer.start();
execFile('npm.cmd', ['--no-update-notifier', 'config', 'get', 'prefix'], { env: process.env }, (e, out) => {
timer.stop();
console.log('Timer1 ', timer.diff() / 1000000, 'ms');
if (e) {
console.error(e);
} else {
console.log(out);
}
});
const timer2 = precise();
timer2.start();
execFile('npm.cmd', ['config', 'get', 'prefix'], { env: process.env }, (e, out) => {
timer2.stop();
console.log('Timer2 ', timer2.diff() / 1000000, 'ms');
if (e) {
console.error(e);
} else {
console.log(out);
}
});
const timer3 = precise();
timer3.start();
execFile('npm.cmd', ['config', 'get', 'prefix'], { env: { ...process.env, NO_UPDATE_NOTIFIER: true } }, (e, out) => {
timer3.stop();
console.log('Timer3 ', timer3.diff() / 1000000, 'ms');
if (e) {
console.error(e);
} else {
console.log(out);
}
}); Output:
It seems that the |
Same result:
|
Thanks. So Timer3 is the only worth in your case. 2 seconds instead of 3 minutes seems a good improvement to me :-) Line 134 in bec291c
Ideally we should also remove the I tried that script on my system and get every numbers around 200 ms (Timer3 being slightly better). Seems there is still room for another improvement. |
I think even if we make it async, the startup time will still take a long time. I am going to change the global module resolution to be off by default. This is something that I don't think many people actually need and after looking again at the telemetry today it does seem that it has had a noticeable impact on startup time. I'll be pushing an update soon that has global resolution off by default and a new config option to enable it. |
Version 3.17.0 is live. This version disables global module resolution by default. Please let me know if this solves the issue. |
I have updated, and I can confirm that behavior seems normal for me. Thanks for getting this resolved quickly 👍 |
I removed the environment variable and upgraded extension from 3.16.0 to 3.17.0. Prettier starts up fast as expected. Thanks @ntotten & @CiGit ! However I still have the same issue with |
Thanks for the quick fix. I'll close the issue for now, although I won't be able to test it myself before Monday. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Prettier takes 3+ minutes to start, prettier is the only activated extension:
System Info:
The text was updated successfully, but these errors were encountered: