hashicorp/nomad · error
unable to determine remaining read limit
Error message
unable to determine remaining read limit
What it means
In streamFile, after the log file rotates, the reader is re-wrapped to preserve the caller's byte limit. The code expects fileReader to be an *io.LimitedReader; if the type assertion fails, the remaining read limit cannot be recovered, so it returns this internal error.
Source
Thrown at client/fs_endpoint.go:770
return err
}
// Get a new reader at offset zero
offset = 0
var err error
file, err = fs.ReadAt(path, offset)
if err != nil {
return err
}
defer file.Close()
if limit <= 0 {
fileReader = file
} else {
// Get the current limit
lr, ok := fileReader.(*io.LimitedReader)
if !ok {
return fmt.Errorf("unable to determine remaining read limit")
}
fileReader = io.LimitReader(file, lr.N)
}
// Store the last event
lastEvent = truncateEvent
continue OUTER
case <-framer.ExitCh():
return nil
case <-ctx.Done():
return nil
case _, ok := <-eofCancelCh:
if !ok {
return nil
}
if err != nil {View on GitHub (pinned to 482b49bf1a)
Solutions
- Retry the request; if reproducible, file a bug with Nomad including the request parameters (origin, offset, limit) and follow flag.
- Avoid unusual offset/limit combinations when following logs; use offset=0 origin=start with follow, or plain non-follow reads.
- Upgrade Nomad to a version where the streaming reader wrapping was fixed.
- Work around by reading logs in bounded chunks via separate non-follow requests instead of one limited follow.
Defensive patterns
Strategy: retry
Type guard
func isReadLimitErr(err error) bool {
return strings.Contains(err.Error(), "unable to determine remaining read limit")
} Try / catch
if err := fetchLimitedLogs(); err != nil {
if isReadLimitErr(err) {
return fetchLogsWithPlainFollow() // drop exotic offset/limit combo
}
return err
} Prevention
- Use standard parameter shapes: origin=start offset=0 follow, or simple non-follow reads.
- Read in bounded chunks with separate requests rather than one limited follow across rotations.
- Report reproducible occurrences as a Nomad client bug with request parameters.
When it happens
Trigger: Reading logs with a finite offset/limit where the internal fileReader type is not an *io.LimitedReader at the time of a rotation — an internal invariant violation of the client's log streaming implementation, typically triggered by concurrent or unusual request shapes (plain stream with limit while rotating).
Common situations: Custom API consumers hitting the fs logs endpoint with odd Origin/offset/limit combinations across a rotation; rarely seen through the official Nomad API client. Mostly a client-internal bug indicator.
Related errors
- failed to stream %q: %v
- state for allocation %s not found on client
- unknown task name %q
- task %q not started yet. No logs available
- failed to list entries: %v
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/52b84bd79fc08eab.
Report an issue: GitHub.