io.ErrNoProgress
GoERRORCriticalIO
multiple Read calls return no data or error
Quick Answer
Fix the underlying Reader so that Read returns either data or a non-nil error on every call.
What this means
Returned by io.Reader wrappers when multiple successive Read calls return 0 bytes and no error, indicating a broken Reader implementation.
Why it happens
- 1Custom io.Reader implementation returns (0, nil) repeatedly instead of io.EOF
- 2Middleware wrapper fails to propagate underlying reader progress
Fix
Fix Reader to return EOF
Fix Reader to return EOF
func (r *MyReader) Read(p []byte) (int, error) {
if r.done { return 0, io.EOF }
return copy(p, r.data), nil
}Why this works
Returning io.EOF when exhausted satisfies the io.Reader contract and stops ErrNoProgress.
Code examples
Detectgo
_, err := io.ReadAll(r)
if errors.Is(err, io.ErrNoProgress) {
fmt.Println("reader stuck")
}Correct EOF returngo
if len(r.data) == 0 {
return 0, io.EOF
}Test with LimitedReadergo
lr := &io.LimitedReader{R: src, N: 100}
io.ReadAll(lr)Same error in other languages
Sources
Official documentation ↗
Go standard library
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev