Candidate megavolt/row254b31300d79onc3d88840c, manifest be63cfbe (7 paths). Dewey APPROVE r1, rev 3006 (#1759 c30173). Gate on Sage's slot by Megavolt, 23:37:27-23:40:52Z onb31300d79: library 77/77, bus 628/628, webui 305 pass with 1 skip (editor rebuild needs esbuild 0.28.2), every scripts/test-*.sh rc 0; the human-cli timeout and library-fetch-failed STATUS mutants killed by their behaviour tests. Landed onto41b0cf755with the candidate's blobs and modes for the 7 paths; c3d88840c..41b0cf755 touches none of them. Merged-tree rerun of library, bus, webui and cli on Sage's slot before the push.
43 lines
1.6 KiB
JavaScript
43 lines
1.6 KiB
JavaScript
// Transport shim used by S4, not a second product CLI. Input and proof never carry service tokens.
|
|
import { randomBytes } from 'node:crypto';
|
|
import { spawnSync } from 'node:child_process';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { readFileSync } from 'node:fs';
|
|
import { Client } from './client.mjs';
|
|
import { readProcess } from './human.mjs';
|
|
const file = fileURLToPath(import.meta.url);
|
|
if (!process.env.MOSAIC_BUS_CLI_NONCE) {
|
|
const child = spawnSync(process.execPath, [file, ...process.argv.slice(2)], {
|
|
stdio: 'inherit',
|
|
env: { ...process.env, MOSAIC_BUS_CLI_NONCE: randomBytes(32).toString('hex') },
|
|
});
|
|
process.exit(child.status ?? 2);
|
|
}
|
|
try {
|
|
const request = JSON.parse(readFileSync(0, 'utf8'));
|
|
if (
|
|
!request ||
|
|
typeof request !== 'object' ||
|
|
Object.keys(request).some((k) => !['business', 'verb', 'args'].includes(k))
|
|
)
|
|
throw Error();
|
|
const me = readProcess(process.pid);
|
|
const client = new Client({
|
|
path: process.argv[2],
|
|
// Row 254: library.sync fetches for up to 100 s and the server holds its socket for 120 s,
|
|
// so wait past that for the server's own answer. Every other verb keeps the 5 s default.
|
|
timeout: request.verb === 'library.sync' ? 130_000 : undefined,
|
|
human: {
|
|
business: request.business,
|
|
pid: me.pid,
|
|
startTime: me.startTime,
|
|
nonce: process.env.MOSAIC_BUS_CLI_NONCE,
|
|
},
|
|
});
|
|
const result = await client.call(request.verb, request.args ?? {});
|
|
process.stdout.write(JSON.stringify(result) + '\n');
|
|
} catch (e) {
|
|
process.stderr.write((/^[a-z-]{1,64}$/.test(e.code ?? '') ? e.code : 'invalid-request') + '\n');
|
|
process.exitCode = 2;
|
|
}
|