Skip to content

debt - log warning when extension watches a URI without provider#277362

Merged
bpasero merged 1 commit intomainfrom
ben/informal-guanaco
Nov 14, 2025
Merged

debt - log warning when extension watches a URI without provider#277362
bpasero merged 1 commit intomainfrom
ben/informal-guanaco

Conversation

@bpasero
Copy link
Member

@bpasero bpasero commented Nov 14, 2025

No description provided.

Copilot AI review requested due to automatic review settings November 14, 2025 08:43
@bpasero bpasero enabled auto-merge (squash) November 14, 2025 08:43
@bpasero bpasero self-assigned this Nov 14, 2025
@vs-code-engineering vs-code-engineering bot added this to the November 2025 milestone Nov 14, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds diagnostic logging to help identify when extensions attempt to watch file system resources for schemes that don't have registered providers. The change logs a warning before attempting the watch operation, making it easier to debug extension issues related to unsupported URI schemes.

Key Changes

  • Adds a check using canHandleResource() to detect if a file system provider exists for the URI scheme
  • Logs a warning message when an extension tries to watch a resource without a provider, including the extension ID and URI for debugging


const canHandleWatcher = await this._fileService.canHandleResource(uri);
if (!canHandleWatcher) {
this._logService.warn(`MainThreadFileSystemEventService#$watch(): cannot watch resource as its scheme is not handled by the file service (extension: ${extensionId}, path: ${uri.toString(true)})`);
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code warns when a resource cannot be watched but continues to attempt the watch operation anyway. This will cause this._fileService.watch() or this._fileService.createWatcher() to fail later when withProvider() is called (lines 241, 258), as withProvider() throws an error when no provider is found.

Consider returning early after logging the warning to avoid unnecessary async operations that will inevitably fail:

if (!canHandleWatcher) {
	this._logService.warn(`MainThreadFileSystemEventService#$watch(): cannot watch resource as its scheme is not handled by the file service (extension: ${extensionId}, path: ${uri.toString(true)})`);
	return;
}

This would make the behavior more explicit and avoid the overhead of attempting an operation that is known to fail.

Suggested change
this._logService.warn(`MainThreadFileSystemEventService#$watch(): cannot watch resource as its scheme is not handled by the file service (extension: ${extensionId}, path: ${uri.toString(true)})`);
this._logService.warn(`MainThreadFileSystemEventService#$watch(): cannot watch resource as its scheme is not handled by the file service (extension: ${extensionId}, path: ${uri.toString(true)})`);
return;

Copilot uses AI. Check for mistakes.
@bpasero bpasero merged commit 0487b0f into main Nov 14, 2025
33 of 34 checks passed
@bpasero bpasero deleted the ben/informal-guanaco branch November 14, 2025 09:02
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants