[Repo Assist] refactor: replace deprecated fs.exists with fs.existsSync in addRootPath#117
Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
Conversation
fs.exists() has been deprecated since Node.js 4.0 and was removed in newer versions of the Node.js docs. Replace it with fs.existsSync() which: 1. Removes the deprecation warning. 2. Fixes a non-deterministic race condition: with the async callback, all workspace folder checks ran concurrently and the last callback to fire would win, making executablePath resolution unpredictable in multi-root workspaces. With existsSync, the first matching folder wins and the function returns immediately, giving consistent, predictable behaviour. 3. Keeps the code simpler — no callback nesting required. Behaviour is unchanged for single-root workspaces (the common case). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 31, 2026
github-actions bot
added a commit
that referenced
this pull request
Apr 2, 2026
Summarises all bug fixes that are ready to ship, drawn from the open Repo Assist PRs (primarily #106, #114, #117, #120, #124 and the earlier consolidated fixes). The version number in package.json is intentionally not changed here (that file requires maintainer action due to protected-file restrictions). This PR exists so the maintainer can review the intended release notes and bump the version when ready. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Replaces the deprecated
fs.exists()callback API withfs.existsSync()in theaddRootPath()method ofextension.js.Problem
fs.exists()has been deprecated since Node.js 4.0.0. Beyond the deprecation, there was a subtle race condition: all workspace folder checks ran concurrently (asynchronous callbacks), so in a multi-root workspace the last callback to fire would "win" and overwritethis.executablePath. This made executable resolution non-deterministic.Additionally, since
addRootPathis called synchronously fromloadSettings,this.executablePathmight not have been updated yet by the timeformat()used it, depending on callback timing.Fix
Replace
fs.exists(path, cb)withfs.existsSync(path):addRootPathfully synchronous, matching its call siteTrade-offs
Behaviour is unchanged for single-root workspaces (the common case).
Test Status
All 7 unit tests pass (
npm run test:unit). No new tests added (the change is to non-testable VS Code API integration code — workspace folder resolution requires a live VS Code host).Closes no specific issue, but is related to the general reliability of multi-root workspace support.