Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/junior/src/chat/sandbox/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,9 @@ export function createSandboxRuntime(
return null;
}
if (isSandboxUnavailableError(error)) {
sandboxRef = undefined;
invalidateSession();
throw error;
return null;
}
throw new Error("sandbox restore failed", { cause: error });
}
Expand All @@ -641,9 +642,10 @@ export function createSandboxRuntime(
await persistSandboxRef({ ...ref, id: hintedSandbox.sandboxId });
return rememberSandbox(hintedSandbox, networkPolicyKey);
} catch (error) {
// Keep the durable VM alive so a later reacquire can reuse it.
if (isSandboxUnavailableError(error)) {
throw error;
sandboxRef = undefined;
invalidateSession();
return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prepare failure orphans restored sandbox

Medium Severity

After Sandbox.get succeeds, a prepare-time unavailable error now clears sandboxRef and returns null, so acquireSandbox builds a new sandbox. That drops the still-running named VM the old path kept for reconnect, and it never stopSessions the retrieved session, so the prior sandbox can keep burning resources until timeout.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 609aef6. Configure here.

}
return failSetup(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1808,8 +1808,8 @@ describe("conversation work execution", () => {
return target.acquireLock(key, ttlMs);
};
}
const value = Reflect.get(target, prop, receiver);
return typeof value === "function" ? value.bind(target) : value;
const value = (target as Record<string | symbol, unknown>)[prop];
return typeof value === "function" ? (value as (...args: unknown[]) => unknown).bind(target) : value;
},
}) as StateAdapter;

Expand Down
Loading