Ensure that file watcher is closed only once for affected file locations that share watcher because of different names but same real path (#50150)

* Add test where clearing affected files watcher that also is shared by real path causes Debug failure

* Ensure that file watcher is closed only once for affected file locations that share watcher because of different names but same real path

* Lift up package json map
This commit is contained in:
Sheetal Nandi
2022-08-03 15:39:07 -07:00
committed by GitHub
parent d6d26430c7
commit bc7786b24e
5 changed files with 188 additions and 15 deletions
+8 -1
View File
@@ -116,7 +116,14 @@ interface Array<T> { length: number; [n: number]: T; }`
function createWatcher<T>(map: MultiMap<Path, T>, path: Path, callback: T): FileWatcher {
map.add(path, callback);
return { close: () => map.remove(path, callback) };
let closed = false;
return {
close: () => {
Debug.assert(!closed);
map.remove(path, callback);
closed = true;
}
};
}
export function getDiffInKeys<T>(map: ESMap<string, T>, expectedKeys: readonly string[]) {