wavetermdev/waveterm · error

seeking file: %w

Error message

seeking file: %w

What it means

tailLogFile failed to Seek to the computed offset (file size minus 16KB, or 0). Seeking is required to read only the tail of a large log; failure indicates the file is not seekable or an I/O error occurred.

Source

Thrown at cmd/wsh/cmd/wshcmd-wavepath.go:108

	}
	defer file.Close()

	// Get file size
	stat, err := file.Stat()
	if err != nil {
		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

View on GitHub (pinned to a4447c1563)

Solutions

  1. Point logging at a regular file (check WAVETERM/wave log dir config).
  2. Re-run on a healthy filesystem; retry transient I/O errors.
  3. Read the whole file manually if small: `cat "$(wsh wavepath log)"`.
  4. Drop --tail and just print the path.

Example fix

// before
_, err = file.Seek(offset, 0)
// after
if _, err = file.Seek(offset, io.SeekStart); err != nil { return fmt.Errorf("seeking file (seekable?): %w", err) }
Defensive patterns

Strategy: fallback

Validate before calling

fi, _ := os.Stat(path); seekable := fi.Mode().IsRegular()

Type guard

func isSeekable(fi os.FileInfo) bool { return fi.Mode().IsRegular() }

Try / catch

if _, err := file.Seek(offset, 0); err != nil {
    // fallback: read whole file from start
    file.Seek(0, io.SeekStart)
    io.Copy(os.Stdout, file)
    return nil
}

Prevention

When it happens

Trigger: `wsh wavepath log --tail` when the log path is a special/non-seekable file (pipe, device node) or an I/O error hits during seek on a network filesystem.

Common situations: Custom WAVE_LOG path pointing to a named pipe, or logs on flaky network mounts.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/77d80c40069dbf37. Report an issue: GitHub.