microsoft/typescript-go · error

unknown error

Error message

unknown error

What it means

Terminal catch-all from the Windows backend: processCompletion received a completion error that is none of the recognized codes (ERROR_OPERATION_ABORTED shutdown, ERROR_INVALID_PARAMETER buffer shrink, ERROR_NOTIFY_ENUM_DIR overflow, ERROR_ACCESS_DENIED with the directory gone). The subscription calls fatal() and delivers the error wrapped with ErrWatchTerminated; the underlying code is not included, so OS-level tracing is needed to diagnose.

Source

Thrown at internal/fswatch/windows.go:109

//     - FILE_ACTION_REMOVED / RENAMED_OLD_NAME → events.remove + tree.remove
//  4. Call dirWatch.notify() to trigger the debouncer.
//
// Error recovery:
//   - ERROR_OPERATION_ABORTED → normal shutdown (CancelIoEx was called).
//   - ERROR_INVALID_PARAMETER → shrink buffer to 64 KB (network share limit).
//   - ERROR_NOTIFY_ENUM_DIR  → ErrOverflow (too many changes queued).
//   - ERROR_ACCESS_DENIED    → check if the watched dir was deleted.
//
// Shutdown:
//   close(stopCh) → CancelIoEx cancels in-flight IO → run() goroutine
//   exits → deferred CloseHandle closes the directory handle → doneCh closed.
// ---------------------------------------------------------------------------

var (
	errGetFileInfo         = errors.New("could not get file information")
	errReadChanges         = errors.New("failed to read changes")
	errGetOverlappedResult = errors.New("GetOverlappedResult failed")
	errUnknown             = errors.New("unknown error")
)

const (
	defaultBufSize = 1024 * 1024
	networkBufSize = 64 * 1024

	notifyChangeFilter = windows.FILE_NOTIFY_CHANGE_FILE_NAME |
		windows.FILE_NOTIFY_CHANGE_DIR_NAME |
		windows.FILE_NOTIFY_CHANGE_SIZE |
		windows.FILE_NOTIFY_CHANGE_LAST_WRITE
)

// windowsBackend.
type windowsBackend struct {
	watcherBase
}

func init() {

View on GitHub (pinned to 1bcfa18d79)

Solutions

  1. Treat it as terminal: on ErrWatchTerminated, call Close() on the Watch
  2. Reproduce while tracing with Process Monitor or ETW to capture the real completion error
  3. If permissions were revoked, restore them and re-subscribe
  4. Exclude the watched tree from over-aggressive filter drivers if the product allows it
Defensive patterns

Strategy: try-catch

Try / catch

func(events []fswatch.Event, err error) {
    if errors.Is(err, fswatch.ErrWatchTerminated) {
        if strings.Contains(err.Error(), "unknown error") {
            // unrecognized completion error: trace with Process Monitor while reproducing
        }
        watch.Close()
        return
    }
    apply(events)
}

Prevention

When it happens

Trigger: Unusual completion errors from filter drivers or filesystem redirectors (ERROR_NOT_SUPPORTED, device-specific codes). ERROR_ACCESS_DENIED when the directory still exists, for example permissions were revoked rather than the directory deleted, which falls through to this default branch.

Common situations: Antivirus/EDR filter drivers interfering with directory handles. Third-party filesystem drivers. Permission changes on the watched directory while it still exists.

Related errors


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