Skip to content

Commit

Permalink
watcher - properly track for service shutdowns and show warning in th…
Browse files Browse the repository at this point in the history
…at case (#132483)
  • Loading branch information
bpasero committed Sep 22, 2021
1 parent adca995 commit 9dd1453
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
11 changes: 11 additions & 0 deletions src/vs/platform/files/node/watcher/nsfw/nsfwWatcherService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,17 @@ export class NsfwWatcherService extends Disposable implements IWatcherService {
this.enospcErrorLogged = true;
this.error('Inotify limit reached (ENOSPC)');
}

// Specially handle this error that indicates the watcher
// has stopped and we need to restart it.
else if (msg.indexOf('Service shutdown unexpectedly') !== -1) {
this.error('Watcher service shutdown unexpectedly (ESHUTDOWN)');
}

// Log any other error
else {
this.error(msg);
}
}

async stop(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/files/test/node/recursiveWatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ flakySuite('Recursive Watcher', () => {
await Promises.rename(newFolderPath, renamedFolderPath);
await changeFuture;

// TODO: case rename is currently broken on macOS
// TODO: case rename is currently broken on macOS (https://github.com/Axosoft/nsfw/issues/146)
if (isWindows) {

// Rename file (same name, different case)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { ExplorerService, UNDO_REDO_SOURCE } from 'vs/workbench/contrib/files/browser/explorerService';
import { SUPPORTED_ENCODINGS } from 'vs/workbench/services/textfile/common/encoding';
import { Schemas } from 'vs/base/common/network';
import { WorkspaceWatcher } from 'vs/workbench/contrib/files/common/workspaceWatcher';
import { WorkspaceWatcher } from 'vs/workbench/contrib/files/browser/workspaceWatcher';
import { editorConfigurationBaseNode } from 'vs/editor/common/config/commonEditorConfig';
import { DirtyFilesIndicator } from 'vs/workbench/contrib/files/common/dirtyFilesIndicator';
import { UndoCommand, RedoCommand } from 'vs/editor/browser/editorExtensions';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import { isAbsolute } from 'vs/base/common/path';
import { isEqualOrParent } from 'vs/base/common/resources';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { IHostService } from 'vs/workbench/services/host/browser/host';

export class WorkspaceWatcher extends Disposable {

Expand All @@ -28,7 +29,8 @@ export class WorkspaceWatcher extends Disposable {
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
@INotificationService private readonly notificationService: INotificationService,
@IOpenerService private readonly openerService: IOpenerService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
@IHostService private readonly hostService: IHostService
) {
super();

Expand Down Expand Up @@ -73,34 +75,34 @@ export class WorkspaceWatcher extends Disposable {
// Forward to unexpected error handler
onUnexpectedError(msg);

// Detect if we run < .NET Framework 4.5
if (msg.indexOf('System.MissingMethodException') >= 0) {
// Detect if we run into ENOSPC issues
if (msg.indexOf('ENOSPC') >= 0) {
this.notificationService.prompt(
Severity.Warning,
localize('netVersionError', "The Microsoft .NET Framework 4.5 is required. Please follow the link to install it."),
localize('enospcError', "Unable to watch for file changes in this large workspace folder. Please follow the instructions link to resolve this issue."),
[{
label: localize('installNet', "Download .NET Framework 4.5"),
run: () => this.openerService.open(URI.parse('https://go.microsoft.com/fwlink/?LinkId=786533'))
label: localize('learnMore', "Instructions"),
run: () => this.openerService.open(URI.parse('https://go.microsoft.com/fwlink/?linkid=867693'))
}],
{
sticky: true,
neverShowAgain: { id: 'ignoreNetVersionError', isSecondary: true, scope: NeverShowAgainScope.WORKSPACE }
neverShowAgain: { id: 'ignoreEnospcError', isSecondary: true, scope: NeverShowAgainScope.WORKSPACE }
}
);
}

// Detect if we run into ENOSPC issues
if (msg.indexOf('ENOSPC') >= 0) {
// Detect when the watcher shutsdown unexpectedly
else if (msg.indexOf('ESHUTDOWN') >= 0) {
this.notificationService.prompt(
Severity.Warning,
localize('enospcError', "Unable to watch for file changes in this large workspace folder. Please follow the instructions link to resolve this issue."),
localize('eshutdownError', "File changes watcher stopped unexpectedly. Please reload the window to enable the watcher again."),
[{
label: localize('learnMore', "Instructions"),
run: () => this.openerService.open(URI.parse('https://go.microsoft.com/fwlink/?linkid=867693'))
label: localize('reload', "Reload"),
run: () => this.hostService.reload()
}],
{
sticky: true,
neverShowAgain: { id: 'ignoreEnospcError', isSecondary: true, scope: NeverShowAgainScope.WORKSPACE }
neverShowAgain: { id: 'ignoreEshutdownError', isSecondary: true, scope: NeverShowAgainScope.WORKSPACE }
}
);
}
Expand Down

0 comments on commit 9dd1453

Please sign in to comment.