Skip to content

Make batch run --follow actually stream, and terminate#16

Merged
lnsp merged 1 commit into
masterfrom
fix/batch-follow
Jul 26, 2026
Merged

Make batch run --follow actually stream, and terminate#16
lnsp merged 1 commit into
masterfrom
fix/batch-follow

Conversation

@lnsp

@lnsp lnsp commented Jul 26, 2026

Copy link
Copy Markdown
Member

--follow previously waited for the execution to finish and printed its output in one block — for a long job, that means staring at nothing for its whole duration.

My first attempt held a server-side follow open instead, and was worse: the server never closes a followed batch log, so the command hung until killed, and because it only attached after the execution left the queue it still showed everything at once. Measured, all nine lines of a 16-second job arrived simultaneously at +49s, then it hung.

Tailing from a byte offset gives both properties:

[+20s] Execution ef4ab622… pending
[+25s] step 1/8
[+26s] step 2/8
[+29s] step 3/8
...
[+40s] slow sample done
[+52s] Execution ef4ab622… succeeded (exit 0)

Lines arrive ~2s apart, matching the job's sleep(2). The loop ends when the execution reaches a terminal state — where the answer to "is there more?" actually lives. The status is read before the log, so the final read can't miss anything written between the two.

batch logs --follow uses the same loop, so it no longer hangs on an already-finished execution.

--follow previously waited for the execution to finish and then printed its
output in one block, which for a long job means staring at nothing for its whole
duration. The first attempt at fixing that held a server-side follow open
instead, and was worse: the server never closes a followed batch log, so the
command hung until killed, and because it attached only after the execution left
the queue it still showed everything at once.

Tailing from a byte offset instead gives both properties. Output appears as it is
produced -- verified against a job that prints every two seconds, and the lines
arrive two seconds apart -- and the loop ends when the execution reaches a
terminal state, which is where the answer to "is there more?" actually lives.
The status is read before the log so a final read cannot miss anything written
between the two.

batch logs --follow uses the same loop, so it no longer hangs on an execution
that has already finished.
@lnsp
lnsp merged commit e1878fa into master Jul 26, 2026
1 check passed
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.

1 participant