debt - log warning when extension watches a URI without provider#277362
debt - log warning when extension watches a URI without provider#277362
Conversation
There was a problem hiding this comment.
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)})`); |
There was a problem hiding this comment.
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.
| 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; |
No description provided.