Skip to content

Commit e5c180c

Browse files
committed
fix(workers): preserve completed container results
1 parent 81cbe0c commit e5c180c

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎src/gateway/worker-workspace-recovery-transcript.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ describe("worker workspace recovery transcript reporting", () => {
6868
throw new Error("expected active worker placement");
6969
}
7070
harness.markEnvironmentOwnerEpoch(active.activeOwnerEpoch);
71+
harness.markEnvironmentNodeDeviceId("workspace-recovery-worker-node");
7172
const claim = placements.claimTurn({
7273
...REQUEST,
7374
claimId: "workspace-recovery-claim",

‎src/node-host/node-worker-supervisor.ts‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,22 +210,23 @@ class NodeWorkerSupervisor {
210210
}
211211
if (active?.state === "running") {
212212
if (active.container) {
213-
const containerState = await this.requireContainerLifecycle().inspect(
214-
active.container,
215-
active,
216-
);
217-
if (containerState === "unknown") {
213+
const inspection = await this.requireContainerLifecycle().inspect(active.container, active);
214+
if (inspection === "unknown") {
218215
return this.store.get(launchId);
219216
}
220-
if (containerState === "reused") {
217+
if (inspection === "reused") {
221218
throw new Error(`node worker launch ${launchId} lost its container ownership`);
222219
}
223-
if (containerState === "live") {
220+
if (inspection === "live") {
224221
const clientState = inspectNodeWorkerProcessIdentity(active.worker);
225222
if (clientState !== "dead" && clientState !== "reused") {
226223
return this.store.get(launchId);
227224
}
228-
await this.stopChild(active, "interrupted");
225+
// Observe the dead attach client's result before fencing its still-running owner.
226+
await active.done;
227+
if (this.active.get(launchId) === active) {
228+
await this.stopChild(active, "interrupted");
229+
}
229230
} else {
230231
await this.cleanupActiveContainer(active);
231232
await active.done;

0 commit comments

Comments
 (0)