Skip to content

fix(logs): show recent entries immediately on /logs#38

Merged
Microck merged 1 commit into
Microck:masterfrom
paulocarinhena:fix/logs-initial-tail
May 11, 2026
Merged

fix(logs): show recent entries immediately on /logs#38
Microck merged 1 commit into
Microck:masterfrom
paulocarinhena:fix/logs-initial-tail

Conversation

@paulocarinhena
Copy link
Copy Markdown
Contributor

@paulocarinhena paulocarinhena commented May 10, 2026

Problem

The /logs screen connected successfully to the SSE endpoint (/api/logs/stream), but it often displayed no logs when opened.

This happened because the watcher only emitted events when the log file size increased. So if logs already existed in the current file but no new lines were written at that moment, the UI stayed empty.

Root cause

In setupLogWatcher() (server/index.js):

  • the initial tail offset (start = Math.max(0, fileSize - 10000)) was computed,
  • but that initial chunk was never read or queued,
  • and streaming only started for future file growth (stat.size > fileSize).

Fix implemented

  • Read the initial tail (last ~10KB) immediately when tailing starts for the current log file,
  • Feed that initial content through processLogLine so SSE subscribers receive immediate history,
  • Keep the existing incremental stream behavior for newly appended lines,
  • Slightly simplify chunk line processing without changing behavior.

Files changed

  • server/index.js
    • added initial log chunk preload in startTailing(),
    • queued those lines for buffer/subscribers,
    • simplified stream.on('data') line splitting.

Expected result

When opening /logs, users now see recent existing entries from the active log file right away, instead of waiting for new log events to appear.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 2026

@paulocarinhena is attempting to deploy a commit to the Projects Team on Vercel.

A member of the Team first needs to authorize it.

@Microck Microck merged commit bc24576 into Microck:master May 11, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants