Skip to content

Commit 1f3d1da

Browse files
committed
Prevent crash when loading workspace with deleted folder
Fixes #3356 Signed-off-by: David Thompson <davthomp@redhat.com>
1 parent 394ab94 commit 1f3d1da

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/serverlessFunction/functionModel.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,18 @@ export class ServerlessFunctionModel implements Disposable {
123123
private addWatchers() {
124124
if (workspace.workspaceFolders) {
125125
for (const workspaceFolder of workspace.workspaceFolders) {
126-
this.watchers.push(
127-
fs.watch(workspaceFolder.uri.fsPath, (_event, filename) => {
128-
if (filename === 'func.yaml') {
129-
this.view.refresh();
130-
}
131-
}),
132-
);
126+
try {
127+
fs.accessSync(workspaceFolder.uri.fsPath);
128+
this.watchers.push(
129+
fs.watch(workspaceFolder.uri.fsPath, (_event, filename) => {
130+
if (filename === 'func.yaml') {
131+
this.view.refresh();
132+
}
133+
}),
134+
);
135+
} catch (e) {
136+
// do not watch non-existent folder
137+
}
133138
}
134139
}
135140
}

0 commit comments

Comments
 (0)