-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
fix: replaced call to fs.pathExists() with fs.existsSync() #1572
fix: replaced call to fs.pathExists() with fs.existsSync() #1572
Conversation
@@ -70,7 +70,7 @@ function findSettingsFiles(docUri?: Uri, isUpdatable?: boolean): Promise<Uri[]> | |||
.map((root) => configFileLocations.map((rel) => path.join(root, rel))) | |||
.reduce((a, b) => a.concat(b), []); | |||
|
|||
const found = possibleLocations.map(async (filename) => ({ filename, exists: await fs.pathExists(filename) })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for picking up on this.
Please use fileExists
from 'common-utils/file.js';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into it, but fileExists()
throws exceptions, which is the point if this PR. Any reason why not to use fs.pathExists()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fs.existsSync
will block, slowing the search down.
Under normal circumstances, fileExists
should not throw an exception. It catches the exception thrown by fs.access and returns false
.
https://github.com/streetsidesoftware/vscode-spell-checker/blob/main/packages/__utils/src/file.ts#L5
Forgive me, I had not fully read your reasons.
This file uses
Yes, this can be very annoying. Let's see if another solution works for you. Changing the code from |
Please try https://github.com/streetsidesoftware/vscode-spell-checker/releases/tag/v2.0.14 to see if that fixes the issue. |
@Jason3S It looks like v2.0.14 fixes the issue, and I'm going to close this PR. |
Replaced call to fs.pathExists() with fs.existsSync().
Reasons:
findSettingsFiles()
looks for a dozen different config files and thrown an exception for every file it can't find (and it does this every 10 seconds)