mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 19:23:24 +00:00
fix(hopper): cancel startup before closing
This commit is contained in:
1 parent
528c05e2fa
commit
6cc2fdf80c
2 files changed
+98
-11
No files matched your search
@@ -254,4 +254,45 @@ describe("HopperClient", () => {
|
||||
expect(firstSettled).toBe(true);
|
||||
await first;
|
||||
});
|
||||
|
||||
it("does not finish startup after an immediate close", async () => {
|
||||
const client = new HopperClient({
|
||||
launcher: new FixtureLauncher(),
|
||||
startupTimeoutMs: 1_000,
|
||||
});
|
||||
clients.push(client);
|
||||
|
||||
const starting = client.start();
|
||||
await client.close();
|
||||
|
||||
const result = await starting;
|
||||
expect(result.ok).toBe(false);
|
||||
if (!result.ok) expect(result.error._tag).toBe("HopperCancelledError");
|
||||
});
|
||||
|
||||
it("starts a fresh session after close completes", async () => {
|
||||
const client = await startClient();
|
||||
await client.close();
|
||||
|
||||
await expect(client.start()).resolves.toEqual({
|
||||
ok: true,
|
||||
value: { name: "REA Hopper bridge", version: "1.0.0" },
|
||||
});
|
||||
});
|
||||
|
||||
it("serializes a restart requested while close is in progress", async () => {
|
||||
const client = await startClient();
|
||||
const closing = client.close();
|
||||
const restarting = client.start();
|
||||
|
||||
await closing;
|
||||
await expect(restarting).resolves.toEqual({
|
||||
ok: true,
|
||||
value: { name: "REA Hopper bridge", version: "1.0.0" },
|
||||
});
|
||||
await expect(client.callTool("echo", { value: "fresh" })).resolves.toEqual({
|
||||
ok: true,
|
||||
value: { value: "fresh" },
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user