diff --git a/CHANGELOG.md b/CHANGELOG.md index 52533c09..43462160 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 up as a fsnotify.Write event. This is never useful, and could result in many spurious Write events. +- windows: return ErrEventOverflow if the buffer is full ([#525]) + + Before it would merely return "short read", making it hard to detect this + error. + - all: return ErrClosed on Add() when the watcher is closed ([#516]) @@ -35,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#516]: https://github.com/fsnotify/fsnotify/pull/516 [#518]: https://github.com/fsnotify/fsnotify/pull/518 [#520]: https://github.com/fsnotify/fsnotify/pull/520 +[#525]: https://github.com/fsnotify/fsnotify/pull/525 ## [1.6.0] - 2022-10-13 diff --git a/backend_fen.go b/backend_fen.go index ad7dac97..f2a5042e 100644 --- a/backend_fen.go +++ b/backend_fen.go @@ -110,6 +110,12 @@ type Watcher struct { Events chan Event // Errors sends any errors. + // + // [ErrEventOverflow] is used to indicate ther are too many events: + // + // - inotify: there are too many queued events (fs.inotify.max_queued_events sysctl) + // - windows: The buffer size is too small; [WithBufferSize] can be used to increase it. + // - kqueue, fen: not used. Errors chan error mu sync.Mutex diff --git a/backend_inotify.go b/backend_inotify.go index 355729a0..25142e70 100644 --- a/backend_inotify.go +++ b/backend_inotify.go @@ -113,6 +113,12 @@ type Watcher struct { Events chan Event // Errors sends any errors. + // + // [ErrEventOverflow] is used to indicate ther are too many events: + // + // - inotify: there are too many queued events (fs.inotify.max_queued_events sysctl) + // - windows: The buffer size is too small; [WithBufferSize] can be used to increase it. + // - kqueue, fen: not used. Errors chan error // Store fd here as os.File.Read() will no longer return on close after diff --git a/backend_kqueue.go b/backend_kqueue.go index 348ef638..cfacedc2 100644 --- a/backend_kqueue.go +++ b/backend_kqueue.go @@ -111,6 +111,12 @@ type Watcher struct { Events chan Event // Errors sends any errors. + // + // [ErrEventOverflow] is used to indicate ther are too many events: + // + // - inotify: there are too many queued events (fs.inotify.max_queued_events sysctl) + // - windows: The buffer size is too small; [WithBufferSize] can be used to increase it. + // - kqueue, fen: not used. Errors chan error done chan struct{} diff --git a/backend_windows.go b/backend_windows.go index 1bdadf3a..585d005a 100644 --- a/backend_windows.go +++ b/backend_windows.go @@ -114,6 +114,12 @@ type Watcher struct { Events chan Event // Errors sends any errors. + // + // [ErrEventOverflow] is used to indicate ther are too many events: + // + // - inotify: there are too many queued events (fs.inotify.max_queued_events sysctl) + // - windows: The buffer size is too small; [WithBufferSize] can be used to increase it. + // - kqueue, fen: not used. Errors chan error port windows.Handle // Handle to completion port @@ -643,7 +649,7 @@ func (w *Watcher) readEvents() { var offset uint32 for { if n == 0 { - w.sendError(errors.New("short read in readEvents()")) + w.sendError(ErrEventOverflow) break } diff --git a/fsnotify.go b/fsnotify.go index 2b570fac..37b34315 100644 --- a/fsnotify.go +++ b/fsnotify.go @@ -47,7 +47,7 @@ const ( // Common errors that can be reported. var ( ErrNonExistentWatch = errors.New("fsnotify: can't remove non-existent watcher") - ErrEventOverflow = errors.New("fsnotify: queue overflow") + ErrEventOverflow = errors.New("fsnotify: queue or buffer overflow") ErrClosed = errors.New("fsnotify: watcher already closed") ) diff --git a/mkdoc.zsh b/mkdoc.zsh index a0659b0c..71ffa883 100755 --- a/mkdoc.zsh +++ b/mkdoc.zsh @@ -171,6 +171,12 @@ EOF errors=$(<