refactor(eval): brainbench exits through the #2084 flushThenExit seam

The hand-rolled grace-tick predates the merge of the central write-fence +
aliveness-grace exit seam; same trap (PGLite exitCode hijack + Bun stdout
discard), now one tested implementation.
This commit is contained in:
Garry Tan
2026-06-12 12:07:44 -07:00
parent f7ff0c2752
commit 5d27cb426f
+7 -6
View File
@@ -18,6 +18,7 @@
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { execSync } from 'node:child_process';
import { flushThenExit } from '../core/cli-force-exit.ts';
import { cliOptsToProgressOptions, getCliOptions } from '../core/cli-options.ts';
import { createProgress } from '../core/progress.ts';
import { buildMetricGlossaryMeta } from '../core/eval/metric-glossary.ts';
@@ -216,14 +217,14 @@ function gitHeadSha(): string {
/**
* Bun discards queued stdout on process.exit and PGLite stomps
* process.exitCode on its own ticks — hold the verdict locally, give the
* event loop one grace window to drain pipes, then exit explicitly
* (learnings pglite-emscripten-hijacks-process-exitcode +
* bun-pipe-stdout-only-flushes-while-alive).
* process.exitCode on its own ticks — hold the verdict locally and exit
* through the #2084 central seam (write-fence + ref'd aliveness grace),
* which exists for exactly this trap.
*/
async function exitWith(code: 0 | 1 | 2): Promise<never> {
await new Promise((resolve) => setTimeout(resolve, 300));
process.exit(code);
flushThenExit(code);
// flushThenExit exits after its bounded fence + grace; never resolve.
return new Promise<never>(() => {});
}
function readBaselineFile(path: string): BrainBenchBaseline {