microsoft/typescript-go · error
GetOverlappedResult failed
Error message
GetOverlappedResult failed
What it means
Terminal error from the Windows run loop: both WaitForSingleObject and GetOverlappedResult failed for a pending overlapped read. The subscription calls fatal(), which removes the watch and delivers the error wrapped with ErrWatchTerminated ('fswatch: watch terminated: GetOverlappedResult failed') on the callback. The watch is dead; no further events are delivered.
Source
Thrown at internal/fswatch/windows.go:108
// - FILE_ACTION_MODIFIED → events.update (→ EventUpdate)
// - 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
}
View on GitHub (pinned to 1bcfa18d79)
Solutions
- Handle ErrWatchTerminated in the callback and call Close() on the Watch
- Re-subscribe after the volume or share is available again
- For removable media, treat termination as expected and gate re-watching on volume presence
- Keep derived state rebuildable so a re-watch can rescan the tree
Defensive patterns
Strategy: try-catch
Type guard
func isWatchTerminated(err error) bool {
return errors.Is(err, fswatch.ErrWatchTerminated)
} Try / catch
func(events []fswatch.Event, err error) {
if errors.Is(err, fswatch.ErrWatchTerminated) {
watch.Close()
go resubscribeWhenVolumeReady(dir)
return
}
apply(events)
} Prevention
- Treat termination on removable media and network shares as expected
- Gate re-watching on volume or share presence, not on a fixed timer
- Keep state rebuildable via rescan after re-subscribe
- Close dead watches to release directory handles
When it happens
Trigger: The directory handle was closed or invalidated while overlapped I/O was pending: drive unmounted, network share dropped, device removed. The wait completed with a failure and the completion query confirmed an error.
Common situations: USB drives unplugged while watched. Mapped drives disconnecting. SMB/iSCSI mounts timing out under load.
Related errors
- could not get file information
- error opening directory: %w
- failed to read changes
- unknown error
- CreateEvent: %w
AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16).
Data as JSON: /api/errors/6e7df449b61d5c22.
Report an issue: GitHub.