* On Windows, libuv reports a watched folder that is being deleted by the * folder's own absolute path (`\\?\D:\…`) and re-arms the read, which fails * the same way at once: thousands of events a second until the stream is * closed, holding a core for good. A directory link in the project w
(dir: string)
| 782 | * project folder that is gone degrades the watcher, closing every stream. |
| 783 | */ |
| 784 | private armGoneCheck(dir: string): void { |
| 785 | if (this.stopped || this.goneChecks.has(dir)) return; |
| 786 | const isRoot = dir === this.projectRoot; |
| 787 | if (!isRoot && !this.dirWatchers.has(dir)) return; // its stream is already closed |
| 788 | const timer = setTimeout(() => { |
| 789 | this.goneChecks.delete(dir); |
| 790 | if (this.stopped) return; |
| 791 | if (isRoot) { |
| 792 | if (!isDirectory(this.projectRoot)) this.degrade(ROOT_GONE_REASON, { projectRoot: this.projectRoot }); |
| 793 | return; |
| 794 | } |
| 795 | if (realpathOrNull(dir) === this.watchedRealDirs.get(dir)) return; |
| 796 | logDebug('Watched link no longer leads to its folder; closing its stream', { dir }); |
| 797 | this.unwatchDir(dir); |
| 798 | this.scheduleTreeRefresh(); |
| 799 | }, GONE_CHECK_DELAY_MS); |
| 800 | timer.unref?.(); |
| 801 | this.goneChecks.set(dir, timer); |
| 802 | } |
| 803 | |
| 804 | /** Close and forget the watch for a directory that errored/was removed. */ |
| 805 | private unwatchDir(dir: string): void { |
no test coverage detected