Repository navigation
Bound the dependency and Auto Find file searches in a home folder workspace - #2002
Draft
Jean-François Gagné (JeanFrancoisGagne) wants to merge 5 commits into
Draft
Jean-François Gagné (JeanFrancoisGagne) wants to merge 5 commits into
Jean-François Gagné (JeanFrancoisGagne) wants to merge 5 commits into
Conversation
findFilesInWorkspace wraps workspace.findFiles with a result cap and a 30 second time limit, linked to the caller's cancellation token. A workspace folder that is the user's home folder, or one of its parents, is not searched and the skip is logged; the other folders are searched through a RelativePattern each. With no home folder open, the call is the same single search as before. findFiles runs ripgrep with --no-ignore and follows symlinks, so a search rooted at the home folder walks the whole profile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
getProjectInstallable ran four findFiles calls with no maxResults. In a workspace opened on the home folder each one walked the whole profile for minutes before the package picker or Quick Create could continue. Each search now goes through findFilesInWorkspace with a cap of 10,000 files and the 30 second time limit, and skips a home folder workspace. The progress and caller tokens still cancel every search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AutoFindProjects.create ran findFiles with no maxResults and no token, so in a workspace opened on the home folder it walked the whole profile before showing the picker. The search now goes through findFilesInWorkspace with a cap of 1,000 marker files and the 30 second time limit, and skips a home folder workspace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VS Code resolves a cancelled findFiles to an empty list, not to the matches found so far (searchService.ts raceCancellationError, mainThreadWorkspace.ts returns null, extHostWorkspace.ts maps null to []). The 30 second limit therefore turned a slow dependency search into "no dependencies", so Quick Create made a venv without them, and a slow Auto Find search into "No projects found". findFilesInWorkspace now passes the caller's token to findFiles unchanged. The dependency search keeps its cancellable progress notification or the caller's token, as before this branch. The tests that checked a linked token go back to checking the caller's token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
getProjectInstallable keeps only files under the projects it is given, but the home folder check skipped the whole workspace folder. With the workspace on the home folder and a project at ~/code/app, Quick Create made the venv without the project's dependencies and the package picker left out its requirements files. findFilesInWorkspace takes neededFolders. In place of a workspace folder that is the home folder or contains it, it searches each needed folder inside it, one RelativePattern each, and still skips a needed folder that is home or contains it. It skips a needed path that is a file or missing, because ripgrep cannot start there and a failed start fails the whole findFiles call. Nested and repeated folders are searched once. The dependency search passes the project folders; Auto Find passes none and keeps skipping the home folder. The vscode mock's RelativePattern now takes a Uri base, as VS Code's does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Jean-François Gagné (@JeanFrancoisGagne) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In a VS Code window opened on the user's home folder (for example
C:\Users\<name>), three actions start file searches that walk the whole profile, AppData and tool caches included, and take minutes:Until ripgrep finishes, the Searching for dependencies notification stays up or Auto Find shows nothing, and ripgrep keeps the CPU and disk busy the whole time.
Cause
workspace.findFilesruns ripgrep with--no-ignoreand, by default,--follow. The excludes these callers pass leave most of a profile in scope, and none of the calls passesmaxResults:src/managers/builtin/pipUtils.ts:459-462(before this PR) runs four searches in parallel ingetProjectInstallable.src/features/creators/autoFindProjects.ts:94(before this PR) runs one search inAutoFindProjects.create.Fix
src/common/workspaceSearch.ts:42addsfindFilesInWorkspace({ label, include, exclude, maxResults, neededFolders, token }):os.homedir()or one of its parents, it makes the same singlefindFilescall as before, plusmaxResults. The caller's token goes tofindFilesunchanged.neededFoldersinside it, oneRelativePatterneach, and skips a needed folder that is itself home or a parent of home. The check usesisSameOrParentPath, so separators, a trailing separator and case on Windows do not matter.traceLognames the folder, the reason and the folders searched instead.findFilescall. Projects can be single.pyfiles. A folder inside another needed folder is searched once.findFilesresolves to an empty list, not to the matches found so far:searchService.tsraces the provider against the token,mainThreadWorkspace.tsreturnsnullon cancel, andextHostWorkspace.tsmapsnullto[]. A limit would turn a slow search into "nothing found".traceWarnrecords a search that reached its cap.pipUtils.ts:431,464-484: each of the four dependency searches goes through the helper withmaxResults10,000 per pattern and the project folders asneededFolders.getProjectInstallablealready keeps only files under those projects, so in a home folder workspace it finds the same files as before without walking the rest of the profile. Quick Create installs from every match under the project, so this cap sits far above what a large monorepo holds. The progress notification and the caller's token still cancel every search.autoFindProjects.ts:20,101: the marker search goes through the helper withmaxResults1,000 and noneededFolders. Each folder with a marker becomes one item in a multi-select picker, and a picker with 1,000 items is already too long to use.In a home folder workspace:
Not changed:
src/features/views/workspacePythonContext.ts:31already passesmaxResults1, and Avoid a full workspace search per Python file event #1999 adds its token.src/features/inlineScript/setupEnvironment.ts:288already passesmaxResults1,000 (MAX_INLINE_SCRIPT_FILES) but no token. A follow-up could move it to the helper.Testing
Windows 11, Node 24.21.0.
npm ci, thennpx tsc -p . --outDir out(thecompile-testscommand): exit 0.npx eslint --config=eslint.config.mjson the seven touched files: exit 0.build/.mocha.unittests.json:npx mocha --no-config --ui tdd --require source-map-support/register --require out/test/unittests.js --timeout 180000 out/test/common/workspaceSearch.unit.test.js out/test/managers/builtin/pipUtils.unit.test.js out/test/features/creators/autoFindProjects.unit.test.jsResult: 88 passing.
out/test/managers/common/packageWatcher.unit.test.js, which also buildsRelativePatternthrough the vscode mock: 39 passing.findFilesfake that returns[]once its token cancels, as VS Code does, the tests for a search that runs for minutes failed for the helper,getProjectInstallableand Auto Find, and so did the tests that check the caller's token reachesfindFiles(73 passing, 9 failing).~/code/appin a home folder workspace got no dependency files, and the helper searched no needed folder (85 passing, 3 failing).findFilescall'smaxResultsand tokengetProjectInstallablesuites now stubgetWorkspaceFolders, which the helper reads.RelativePatternaccepts aUribase, as VS Code's does.Context
#1989 reports a VS Code window opened on the home folder that froze a Windows laptop. #1999 fixes the
workspaceHasPythonwatcher behind that report. Reviewing #1999 turned up these unboundedfindFilescalls, which #1999 does not touch. They run on user actions rather than on file events, so each action starts one walk instead of one per changed file, but each walk still covers the whole profile.🤖 Generated with Claude Code