microsoft/typescript-go · error
could not get file information
Error message
could not get file information
What it means
Static error returned synchronously from WatchDirectory on Windows when GetFileInformationByHandle fails immediately after CreateFile succeeded while opening the watched directory in newWindowsSubscription. The handle is closed and the sentinel is returned as-is (no errno attached), so the caller sees exactly 'could not get file information'. It is rare by construction: the open worked but the metadata query failed.
Source
Thrown at internal/fswatch/windows.go:106
// 3. Walk the FILE_NOTIFY_INFORMATION linked list:
// - FILE_ACTION_ADDED / RENAMED_NEW_NAME → events.create (→ EventUpdate)
// - 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 {
watcherBaseView on GitHub (pinned to 1bcfa18d79)
Solutions
- Retry WatchDirectory after a short backoff; transient handle failures usually clear on the next attempt
- Verify with os.Stat that the path is still a readable directory, then re-subscribe
- For network shares, stabilize the connection or watch a local mirror
- If it persists, trace OS-level failures with Process Monitor to find the interfering driver
Defensive patterns
Strategy: retry
Validate before calling
if _, err := os.Stat(dir); err != nil {
return err // wait for the directory/share before subscribing
} Try / catch
watch, err := w.WatchDirectory(dir, cb)
if err != nil && err.Error() == "could not get file information" {
// transient: retry with backoff
time.Sleep(250 * time.Millisecond)
watch, err = w.WatchDirectory(dir, cb)
} Prevention
- Subscribe only when the target directory is confirmed present
- Prefer stable local directories over flaky network shares for watch roots
- Retry transient metadata failures once or twice before reporting
- Watch for filter-driver interference when errors cluster in time
When it happens
Trigger: The directory handle is invalidated between CreateFile and the metadata call: the network share dropped, the device was removed, or a filter driver interfered. Filesystem corruption or driver bugs can also produce it.
Common situations: UNC network paths on flaky links during subscribe. Removable media ejected at that exact moment. Antivirus or ERM filter drivers that quarantine the directory between the two calls.
Related errors
- GetOverlappedResult failed
- error opening directory: %w
- invalid handle: %w
- Child process exited with code ${this.child.exitCode} before
- SyncRpcChannel: timed out connecting to named pipe
AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16).
Data as JSON: /api/errors/2b260dc7510dc609.
Report an issue: GitHub.