fix(terminal): catch ENOPRO in getCwdResource when file:// provider absent in VS Code web#317780
Merged
meganrogge merged 2 commits intoJun 5, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the terminal instance working-directory URI resolution in VS Code web/server scenarios by preventing getCwdResource() from throwing when the FileService cannot handle the produced URI (notably when a file:// provider is absent), allowing callers (including agent terminal tools) to fall back gracefully.
Changes:
- Wrap
TerminalInstance.getCwdResource()URI creation/existence validation intry/catch. - Return
undefinedinstead of propagating provider-related errors (e.g. ENOPRO) fromfileService.exists.
…e on VS Code web In VS Code Server (server-linux-x64-web) accessed via browser, the terminal's remoteAuthority is falsy so URI.file() is produced in getCwdResource(). The browser FileService has no file:// provider registered (only the remote provider), causing ENOPRO on every Copilot agent tool call. Replace the blanket try/catch with a targeted canHandleResource() guard so that provider errors are detected before calling exists(), while other genuine errors from fileURI()/URI.file() remain surfaced to callers. Also adds a unit test covering the ENOPRO / provider-absent scenario. Discovered during deployment: workbench.web.main.internal.js (the server-side agentHost bundle) requires the same fix as workbench.js (the browser-side bundle), since the agentHost process loads the server bundle independently. Fixes: getCwdResource() returning ENOPRO when file:// provider absent Addresses: Copilot PR review feedback on blanket catch scope and missing test
b90e189 to
68619df
Compare
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @anthonykim1Matched files:
|
meganrogge
approved these changes
Jun 5, 2026
meganrogge
approved these changes
Jun 5, 2026
lramos15
approved these changes
Jun 5, 2026
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.
Problem
Fixes #317329 (related — same deployment scenario, different subsystem)
When using VS Code Server (
server-linux-x64-web) accessed via a browser, callinggetCwdResource()on a terminal instance throws:This surfaces as a failure on every Copilot agent terminal tool invocation (the agent host calls
getCwdResource()to resolve the working directory before running a shell command). Any other caller that relies on this method is similarly broken.Root cause
getCwdResource()interminalInstance.tshas two branches:In a self-hosted
server-linux-x64-webdeployment without an explicitremoteAuthorityheader,this.remoteAuthorityis falsy from the terminal's perspective. Theelsebranch fires, producing afile:///workspaceURI. The browserFileServicehas nofile://provider registered — only the remote provider — so_fileService.exists(resource)throwsENOPRO.This
elsebranch is desktop/Electron-only code: in a correct remote-web contextremoteAuthoritywould be set and_pathService.fileURI()would be used instead.Fix
Wrap the function body in
try/catchso that provider errors (ENOPRO or otherwise) returnundefined, allowing callers to fall back to the default CWD rather than propagating the error. The existing logic is preserved — only the error path is changed.Testing
Verified against a running
server-linux-x64-webinstance (v1.121.0, commitf6cfa2ea) in a containerised deployment:getCwdResourcereturnsundefinedand the tool falls back to the default CWDNotes
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts_pathService.fileURI(); this PR takes the minimal safe approach of catching the error