benbjohnson/litestream · error

webdav: cannot skip offset in file %q: %w

Error message

webdav: cannot skip offset in file %q: %w

What it means

After opening the full stream, OpenLTXFile skips `offset` bytes using io.CopyN into io.Discard. If the stream ends before the offset is reached this is treated as an empty file (EOF handled), so this error only fires when the skip fails for another reason — a read error or write error to Discard mid-skip.

Source

Thrown at webdav/replica_client.go:337

		return internal.LimitReadCloser(rc, size), nil
	}

	if offset > 0 {
		rc, err := client.ReadStream(filename)
		if err != nil {
			if os.IsNotExist(err) || gowebdav.IsErrNotFound(err) {
				return nil, os.ErrNotExist
			}
			return nil, fmt.Errorf("webdav: cannot read file %q: %w", filename, err)
		}

		if _, err := io.CopyN(io.Discard, rc, offset); err != nil {
			if err == io.EOF || err == io.ErrUnexpectedEOF {
				_ = rc.Close()
				return io.NopCloser(bytes.NewReader(nil)), nil
			}
			_ = rc.Close()
			return nil, fmt.Errorf("webdav: cannot skip offset in file %q: %w", filename, err)
		}

		return rc, nil
	}

	rc, err := client.ReadStream(filename)
	if err != nil {
		if os.IsNotExist(err) || gowebdav.IsErrNotFound(err) {
			return nil, os.ErrNotExist
		}
		return nil, fmt.Errorf("webdav: cannot read file %q: %w", filename, err)
	}
	return rc, nil
}

func (c *ReplicaClient) DeleteLTXFiles(ctx context.Context, a []*ltx.FileInfo) error {
	client, err := c.init(ctx)
	if err != nil {

View on GitHub (pinned to 4ed7a308f6)

Solutions

  1. Retry the read; connection resets are usually transient
  2. Check proxy idle/read timeouts and raise them for large files
  3. Verify network stability between litestream and the WebDAV server
  4. If the server supports ranges, prefer code paths that use ReadStreamRange
Defensive patterns

Strategy: retry

Validate before calling

// ensure stable connectivity for large offsets
conn, err := net.DialTimeout("tcp", host, 5*time.Second)
if err != nil { return err }; conn.Close()

Try / catch

rc, err := OpenLTXFile(ctx, info)
if err != nil && strings.Contains(err.Error(), "cannot skip offset") {
    // transient mid-stream failure: retry with backoff
}

Prevention

When it happens

Trigger: The underlying connection errors out while discarding bytes (connection reset mid-stream, TLS truncation), i.e. reading past EOF fails hard rather than cleanly.

Common situations: Unstable network dropping long skip operations on big LTX files, proxies killing idle/slow responses, server prematurely closing connections.

Related errors


AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06). Data as JSON: /api/errors/b915ee8f33d95c73. Report an issue: GitHub.