diff --git a/lib/omp/rpc-utility.test.mjs b/lib/omp/rpc-utility.test.mjs new file mode 100644 index 000000000..3fd71cc19 --- /dev/null +++ b/lib/omp/rpc-utility.test.mjs @@ -0,0 +1,10 @@ +import assert from "node:assert/strict"; +import { readFile } from "node:fs/promises"; +import test from "node:test"; + +test("utility RPC processes negotiate v2 before sending commands", async () => { + const source = await readFile(new URL("./rpc-utility.ts", import.meta.url), "utf8"); + const negotiations = source.match(/await proc\.negotiateProtocol\(ready\)/g) ?? []; + + assert.equal(negotiations.length, 2); +}); diff --git a/lib/omp/rpc-utility.ts b/lib/omp/rpc-utility.ts index dfed589fa..76a4a8f7b 100644 --- a/lib/omp/rpc-utility.ts +++ b/lib/omp/rpc-utility.ts @@ -116,7 +116,8 @@ async function startProcess(state: UtilityRpcState): Promise { }, }); try { - await proc.waitReady(READY_TIMEOUT_MS); + const ready = await proc.waitReady(READY_TIMEOUT_MS); + await proc.negotiateProtocol(ready); } catch (error) { void proc.dispose(); throw error; @@ -165,7 +166,8 @@ export async function runIsolatedUtilityCommand( env: options.env, }); try { - await proc.waitReady(READY_TIMEOUT_MS); + const ready = await proc.waitReady(READY_TIMEOUT_MS); + await proc.negotiateProtocol(ready); return await proc.sendCommand(command, options.timeoutMs ?? DEFAULT_COMMAND_TIMEOUT_MS); } finally { // Await the child's exit (not fire-and-forget): callers like the