A failed write to the log destination latches badbit on the output
stream, and ostream discards every subsequent insertion for as long as
it stays set. Nothing in bees ever checks or clears it, so a single
transient write error silences the daemon permanently: it keeps
scanning, deduping and updating its status file, but never writes
another log line, and exits 0 at the end as if nothing happened.
This is not hypothetical. A test run logging to a virtiofs mount
stopped emitting after five minutes and stayed silent for the next
half hour while continuing to work normally; strace confirmed the
process had stopped issuing writes to the log fd entirely. The same
binary and configuration logging to local disk ran past that point and
kept going.
The line that hit the error is lost either way, and retrying it risks
blocking behind a destination that is still broken, so drop it and
reset the state instead. One bad write then costs one line rather
than the remainder of the run.
Assisted-by: Claude-Code:claude-opus-5
os << (header + body.substr(start) + "\n") << flush;
start = body.size();
}
+ // A failed write to the log destination -- a full filesystem, or
+ // a hiccup on a virtiofs or NFS mount -- latches badbit, and
+ // ostream then discards every later insertion while it stays
+ // set. bees keeps running and doing work but never logs another
+ // line, with no diagnostic and no exit status to show for it.
+ // The line that hit the error is lost either way, so clear the
+ // state and let the next one through: one bad write costs one
+ // line, not the rest of the run.
+ os.clear();
}
}