microsoft/typescript-go · error

%w: watched directory removed

Error message

%w: watched directory removed

What it means

Error "%w: watched directory removed" thrown in microsoft/typescript-go.

Source

Thrown at internal/fswatch/inotify_linux.go:388

					}
					kept = append(kept, s)
				}
				if len(kept) == 0 {
					_, _ = unix.InotifyRmWatch(b.inotify, uint32(wd))
					delete(b.subscriptions, wd)
				} else {
					b.subscriptions[wd] = kept
				}
			}
		}
		w.events.remove(path)
		// If the watched root itself is gone the kernel has already
		// auto-removed every wd associated with this dirWatch and no
		// further events will fire. Surface ErrWatchTerminated so the
		// caller knows to clean up; the delete event above still
		// flows through the same callback.
		if isSelfEvent && path == w.dir {
			w.events.setError(fmt.Errorf("%w: watched directory removed", ErrWatchTerminated))
		}
	}
	return true
}

// closeWatch mirrors `inotifyBackend::closeWatch`. Iterates every wd that
// referenced w and removes the matching subscriptions. If a kernel
// InotifyRmWatch fails we keep processing remaining wds and return the
// first error encountered; bailing early would leave the internal state
// half-cleaned and the caller's dirWatch hanging off other wds.
func (b *inotifyBackend) closeWatch(w *dirWatch) error {
	var firstErr error
	for wd, list := range b.subscriptions {
		kept := list[:0]
		removedAny := false
		for _, s := range list {
			if s.dirWatch == w {
				removedAny = true

View on GitHub (pinned to 1bcfa18d79)

When it happens

Trigger: Thrown at internal/fswatch/inotify_linux.go:388 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16). Data as JSON: /api/errors/ee9c26bf1bee0a5e. Report an issue: GitHub.