Fix stale error lines bleeding into next Typst compile log
Build and Deploy Verso / deploy (push) Failing after 36m24s

When typst watch doesn't emit "compiled with errors" after a failed
compile, currentLines accumulates indefinitely. The next successful
compile then flushes the buffer including the stale error from the
prior cycle. Reset currentLines at the start of each compile cycle
("[HH:MM:SS] compiling ...") so each log only contains output from
one compile.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
claude
2026-06-07 15:10:59 +00:00
parent 5a85e1b9d8
commit 2ead377ebc
+12
View File
@@ -17,6 +17,12 @@ const MAX_LOG_LINES = 500
// How long to wait for the watcher process to emit its first output.
const WATCH_START_TIMEOUT_MS = 15_000
// Matches the start-of-compile marker typst watch emits before each cycle:
// "[HH:MM:SS] compiling ..."
// Used to reset the line buffer so stale output from a failed compile that
// didn't emit a "compiled with errors" footer cannot bleed into the next log.
const COMPILE_START_RE = /^\[\d{2}:\d{2}:\d{2}\] compiling/
// Matches the three terminal lines that typst watch emits at the end of each
// compile cycle regardless of outcome:
// "[HH:MM:SS] compiled successfully in 42ms"
@@ -191,6 +197,12 @@ function _onWatcherData(compileName, chunk) {
entry.accumulator = lines.pop() // keep the incomplete trailing fragment
for (const line of lines) {
if (COMPILE_START_RE.test(line)) {
// New compile cycle — discard any output left over from a previous
// failed compile that didn't emit a "compiled with errors" footer.
entry.currentLines = []
}
entry.currentLines.push(line)
if (entry.currentLines.length > MAX_LOG_LINES) {
entry.currentLines.shift()