Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit fa7db192961de22402bd4f165129c0473d1ea10a
parent 31cedd281b29d7496825441766b24537b5b50d4f
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 16 Oct 2026 19:10:01 -0400

common: a job's log is flushed before the job settles — runManagedCommand/runManagedFunction ended the write stream and settled `done` at once, so a caller reading the log on done (an @@ summary line, ops --wait) could miss its last lines (the mirror-scan test failed on it under a loaded suite); a stream that errored settles too

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mcommon/jobs/streamCommand.ts | 24++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/common/jobs/streamCommand.ts b/common/jobs/streamCommand.ts @@ -271,8 +271,16 @@ export async function runManagedCommand( safe.safeEnqueue(`\n[error] ${(err as Error).message}\n`); registry.finalize(id, "failed"); }) - .finally(() => { - fileStream?.end(); + .finally(async () => { + // The log is FLUSHED before the job settles: a caller that reads it on + // `done` (a summary `@@…` line, `pnpm ops … --wait`) would otherwise race + // the write stream and miss its last lines. + // A stream that errored never finishes: settle on its error too, never hang. + await new Promise<void>((resolve) => { + if (!fileStream) return resolve(); + fileStream.once("error", () => resolve()); + fileStream.end(() => resolve()); + }); safe.safeClose(); requestSnapshotOnFinish(id, opts); // Persist terminal state (status/endedAt/exitCode now set by finalize). @@ -463,8 +471,16 @@ export async function runManagedFunction( onLog(`[error] ${(err as Error).message}`); registry.finalize(id, "failed"); }) - .finally(() => { - fileStream?.end(); + .finally(async () => { + // The log is FLUSHED before the job settles: a caller that reads it on + // `done` (a summary `@@…` line, `pnpm ops … --wait`) would otherwise race + // the write stream and miss its last lines. + // A stream that errored never finishes: settle on its error too, never hang. + await new Promise<void>((resolve) => { + if (!fileStream) return resolve(); + fileStream.once("error", () => resolve()); + fileStream.end(() => resolve()); + }); safe.safeClose(); requestSnapshotOnFinish(id, opts); // Persist terminal state (status/endedAt/exitCode now set by finalize).