wavetermdev/waveterm · error
reading file: %w
Error message
reading file: %w
What it means
After seeking, tailLogFile's Read on the log file returned a non-EOF error, so it cannot deliver the buffered tail of the log. EOF is deliberately tolerated since Read at EOF is expected for small files.
Source
Thrown at cmd/wsh/cmd/wshcmd-wavepath.go:114
return fmt.Errorf("getting file stats: %w", err)
}
// Read last 16KB or whole file if smaller
readSize := int64(16 * 1024)
var offset int64
if stat.Size() > readSize {
offset = stat.Size() - readSize
}
_, err = file.Seek(offset, 0)
if err != nil {
return fmt.Errorf("seeking file: %w", err)
}
buf := make([]byte, readSize)
n, err := file.Read(buf)
if err != nil && err != io.EOF {
return fmt.Errorf("reading file: %w", err)
}
buf = buf[:n]
// Skip partial line at start if we're not at beginning of file
if offset > 0 {
idx := bytes.IndexByte(buf, '\n')
if idx >= 0 {
buf = buf[idx+1:]
}
}
// Split into lines
lines := bytes.Split(buf, []byte{'\n'})
// Take last 100 lines if we have more
startIdx := 0
if len(lines) > 100 {
startIdx = len(lines) - 100View on GitHub (pinned to a4447c1563)
Solutions
- Re-run the command; rotation races are transient.
- Check `dmesg`/system logs for disk I/O errors.
- Move logs to a local disk instead of a network mount.
- Use `wsh wavepath log` (no --tail) and tail with system tools.
Example fix
// before
n, err := file.Read(buf)
if err != nil && err != io.EOF { return fmt.Errorf("reading file: %w", err) }
// after
n, err := io.ReadFull(file, buf)
if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { return fmt.Errorf("reading file: %w", err) } Defensive patterns
Strategy: retry
Try / catch
n, err := file.Read(buf)
if err != nil && err != io.EOF {
if isTransient(err) { return retryTail(path) }
return fmt.Errorf("reading file: %w", err)
} Prevention
- Avoid racing log rotation with the tail read.
- Keep logs off unreliable network mounts.
- Retry once on transient I/O errors before surfacing.
When it happens
Trigger: `wsh wavepath log --tail` when the underlying file disappears mid-read (rotation/delete), hardware or network I/O error, or interruption while reading from an unstable mount.
Common situations: Log rotation racing the read, disks dropping errors, or reading logs over SSHFS/NFS mounts that time out.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- tailing log file: %w
- opening log file: %w
- getting file stats: %w
- seeking file: %w
- no window found with workspace ${data.workspaceid}
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/0d4ba993d7b9ffa9.
Report an issue: GitHub.