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/fsevents_darwin.go:576

			// Skip events for the watched directory itself unless it's been
			// removed. fseventsd reports a change on the watched dir when a
			// child is added or removed; subscribers observe changes *within*
			// the directory, not the dir's own metadata churn.
			// (A removal of the dir is still propagated because Watcher
			// relies on it to tear down the stream.)
			if displayPath == w.dir && !isRemoved && !isRenamed {
				continue
			}

			switch {
			case isRemoved && !isCreated:
				if displayPath == w.dir {
					w.events.removeWatchRootAt(displayPath, eventID)
				} else {
					w.events.removeAt(displayPath, eventID)
				}
				if w.terminateCallbacksForDeletedRoot(displayPath, eventID, fmt.Errorf("%w: watched directory removed", ErrWatchTerminated)) {
					touched[w] = struct{}{}
				}
				if displayPath == w.dir {
					watch.state.terminated.Store(true)
					w.events.setError(fmt.Errorf("%w: watched directory removed", ErrWatchTerminated))
				}
			case isRenamed || (isRemoved && isCreated):
				if !pathExistsKnown {
					var st unix.Stat_t
					pathExists = unix.Lstat(rawPath, &st) == nil
					pathExistsKnown = true
				}
				if pathExists {
					if displayPath == w.dir {
						w.events.updateWatchRootAt(displayPath, eventID)
					} else {
						w.events.updateAt(displayPath, eventID)
					}

View on GitHub (pinned to 1bcfa18d79)

When it happens

Trigger: Thrown at internal/fswatch/fsevents_darwin.go:576 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/97fb81a095466b88. Report an issue: GitHub.