{"record":{"id":"6e7df449b61d5c22","repo":"microsoft/typescript-go","slug":"getoverlappedresult-failed","errorCode":null,"errorMessage":"GetOverlappedResult failed","messagePattern":"GetOverlappedResult failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/fswatch/windows.go","lineNumber":108,"sourceCode":"//     - FILE_ACTION_MODIFIED                  → events.update (→ EventUpdate)\n//     - FILE_ACTION_REMOVED / RENAMED_OLD_NAME → events.remove + tree.remove\n//  4. Call dirWatch.notify() to trigger the debouncer.\n//\n// Error recovery:\n//   - ERROR_OPERATION_ABORTED → normal shutdown (CancelIoEx was called).\n//   - ERROR_INVALID_PARAMETER → shrink buffer to 64 KB (network share limit).\n//   - ERROR_NOTIFY_ENUM_DIR  → ErrOverflow (too many changes queued).\n//   - ERROR_ACCESS_DENIED    → check if the watched dir was deleted.\n//\n// Shutdown:\n//   close(stopCh) → CancelIoEx cancels in-flight IO → run() goroutine\n//   exits → deferred CloseHandle closes the directory handle → doneCh closed.\n// ---------------------------------------------------------------------------\n\nvar (\n\terrGetFileInfo         = errors.New(\"could not get file information\")\n\terrReadChanges         = errors.New(\"failed to read changes\")\n\terrGetOverlappedResult = errors.New(\"GetOverlappedResult failed\")\n\terrUnknown             = errors.New(\"unknown error\")\n)\n\nconst (\n\tdefaultBufSize = 1024 * 1024\n\tnetworkBufSize = 64 * 1024\n\n\tnotifyChangeFilter = windows.FILE_NOTIFY_CHANGE_FILE_NAME |\n\t\twindows.FILE_NOTIFY_CHANGE_DIR_NAME |\n\t\twindows.FILE_NOTIFY_CHANGE_SIZE |\n\t\twindows.FILE_NOTIFY_CHANGE_LAST_WRITE\n)\n\n// windowsBackend.\ntype windowsBackend struct {\n\twatcherBase\n}\n","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/fswatch/windows.go#L90-L126","documentation":"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.","triggerScenarios":"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.","commonSituations":"USB drives unplugged while watched. Mapped drives disconnecting. SMB/iSCSI mounts timing out under load.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isWatchTerminated(err error) bool {\n    return errors.Is(err, fswatch.ErrWatchTerminated)\n}","tryCatchPattern":"func(events []fswatch.Event, err error) {\n    if errors.Is(err, fswatch.ErrWatchTerminated) {\n        watch.Close()\n        go resubscribeWhenVolumeReady(dir)\n        return\n    }\n    apply(events)\n}","preventionTips":["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"],"tags":["windows","overlapped-io","terminal","removable-media","network-share"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}