From 92fcb70d938144cc530513399e8d487788961509 Mon Sep 17 00:00:00 2001 From: satoshi Date: Tue, 28 Apr 2026 23:25:43 +0300 Subject: [PATCH] Fix tailer cursor not saved when context cancelled at EOF poll When the tailer is parked at EOF polling for new log lines (the steady state between blocks), a context cancellation causes sleep() to return false, which previously triggered a bare return without force-saving the cursor. On restart the throttled saveCursor(false) call had last fired when the file was at offset 0 (empty on first open), so the tailer replayed the entire log from the beginning. The fix adds saveCursor(true) before the return so the cursor is always flushed at the position we actually read to, regardless of when the process is stopped. Found by TestTailerRun_CursorResume, which expects a resumed tailer to see only newly appended lines and not replay previously processed ones. --- api/internal/logmon/tailer.go | 1 + 1 file changed, 1 insertion(+) diff --git a/api/internal/logmon/tailer.go b/api/internal/logmon/tailer.go index 5cd0c26..a6f1309 100644 --- a/api/internal/logmon/tailer.go +++ b/api/internal/logmon/tailer.go @@ -235,6 +235,7 @@ func (t *Tailer) Run(ctx context.Context) { } } if !sleep(ctx, t.PollWait) { + saveCursor(true) return } }