Skip to content

Commit acc17e1

Browse files
roblourensCopilot
andauthored
Fix disposable leak warning from in-process node.js file watcher (#320246)
NodeJSFileWatcherLibrary.watch() awaited doWatch() and then called this._register() on the result. If the watcher was disposed during that async window, _store was already disposed, producing a "disposable added to a disposed store" warning and leaking the fs.watch handle. Use thenRegisterOrDispose so the resolved handle is disposed instead of registered when the watcher is torn down mid-flight. This is common in the agent host where non-recursive watching runs in-process and SessionCustomizationDiscovery churns watchers on file changes. Fixes #320245 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9146ae1 commit acc17e1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/vs/platform/files/node/watcher/nodejs/nodejsWatcherLib.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class NodeJSFileWatcherLibrary extends Disposable {
112112
return;
113113
}
114114

115-
this._register(await this.doWatch(stat.isDirectory()));
115+
await thenRegisterOrDispose(this.doWatch(stat.isDirectory()), this._store);
116116
} catch (error) {
117117
if (error.code !== 'ENOENT') {
118118
this.error(error);

0 commit comments

Comments
 (0)