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/windows.go:340

		switch {
		case errors.Is(callErr, windows.ERROR_OPERATION_ABORTED):
			return true
		case errors.Is(callErr, windows.ERROR_INVALID_PARAMETER):
			s.mu.Lock()
			s.bufBytes = networkBufSize
			s.mu.Unlock()
			return false
		case errors.Is(callErr, windows.ERROR_NOTIFY_ENUM_DIR):
			s.dirWatch.events.setError(ErrOverflow)
			s.dirWatch.notify()
			return false
		case errors.Is(callErr, windows.ERROR_ACCESS_DENIED):
			// Possibly the watched dir was deleted; check and handle.
			pathPtr, _ := windows.UTF16PtrFromString(s.dirWatch.physicalDir)
			attrs, err := windows.GetFileAttributes(pathPtr)
			if err != nil || attrs == windows.INVALID_FILE_ATTRIBUTES || attrs&windows.FILE_ATTRIBUTE_DIRECTORY == 0 {
				s.dirWatch.events.remove(s.dirWatch.dir)
				s.dirWatch.events.setError(fmt.Errorf("%w: watched directory removed", ErrWatchTerminated))
				s.dirWatch.notify()
				s.stop()
				return true
			}
			fallthrough
		default:
			s.fatal(&dirWatchError{err: errUnknown, dirWatch: s.dirWatch})
			return true
		}
	}

	// Walk the FILE_NOTIFY_INFORMATION chain.
	offset := uint32(0)
	if bytes == 0 {
		bytes = uint32(len(buf))
	}
	for offset < bytes {
		fni := (*windows.FileNotifyInformation)(unsafe.Pointer(&buf[offset]))

View on GitHub (pinned to 1bcfa18d79)

When it happens

Trigger: Thrown at internal/fswatch/windows.go:340 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/558b7c8048b7ce61. Report an issue: GitHub.