94ee2f99ac
Replace flaky time-based heuristic (sleep + 500ms race) with a proper
ready-signal protocol. The RPC server now emits {"type":"ready"} on
stdout when initialized, and the client waits for that signal instead
of guessing based on timing.
Fixes CI failure where the process took longer than 600ms to reach
provider validation (due to auth discovery + model registry refresh),
causing start() to resolve even when the process was about to exit.
18 lines
607 B
TypeScript
18 lines
607 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import * as path from "node:path";
|
|
import { RpcClient } from "@oh-my-pi/pi-coding-agent/modes/rpc/rpc-client";
|
|
|
|
describe("RpcClient.start", () => {
|
|
test("rejects when RPC process exits immediately", async () => {
|
|
using client = new RpcClient({
|
|
cliPath: path.join(import.meta.dir, "..", "src", "cli.ts"),
|
|
cwd: path.join(import.meta.dir, ".."),
|
|
provider: "__missing_provider__",
|
|
model: "claude-sonnet-4-5",
|
|
env: { PI_NO_TITLE: "1" },
|
|
});
|
|
|
|
await expect(client.start()).rejects.toThrow(/Unknown provider.*__missing_provider__/);
|
|
});
|
|
});
|