Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Cloud background status: only follow-up reads stop at the requested wait

milind-soni2a4aefe7d7e6
diff --git a/server/cloud-computer-background.test.ts b/server/cloud-computer-background.test.ts
index f32914c2d5..ad9e9358f6 100644
--- a/server/cloud-computer-background.test.ts
+++ b/server/cloud-computer-background.test.ts
@@ -211,14 +211,6 @@ describe.each([
server.closeAllConnections();
});
- it("bounds a stalled initial status read by the requested wait", async () => {
- const processId = await start();
- hold = true;
- const result = await call("exec_status", { process_id: processId, wait_seconds: 1 }).done;
- expect(result).toMatchObject({ isError: true, content: [{ text: expect.stringContaining("Nothing was changed; call exec_status again") }] });
- server.closeAllConnections();
- });
-
it("propagates cancellation during a follow-up status read", async () => {
const processId = await start();
holdStatusAfterFirst = true;
diff --git a/server/cloud-computer-background.ts b/server/cloud-computer-background.ts
index f4d2d91636..ce75261c9a 100644
--- a/server/cloud-computer-background.ts
+++ b/server/cloud-computer-background.ts
@@ -157,7 +157,8 @@ export async function backgroundStatus(
let last: { body: any; observedAt: number } | undefined;
for (;;) {
assertBoatNotDeleting(boxId);
- const deadline = waitMs ? clock.timeout(Math.max(1, until - clock.now())) : null;
+ // The first read keeps the call's own time limit: a short wait must not cut off a status a slow Boat answer is about to give.
+ const deadline = waitMs && last ? clock.timeout(Math.max(1, until - clock.now())) : null;
const readSignal = deadline ? AbortSignal.any([signal, deadline]) : signal;
let response: Response, body: any;
try {