Skip to content

Commit 460477f

Browse files
d-csclaude
andcommitted
fix(run-ops split): don't drop queue ack/waitpoint completion when env resolution is unavailable
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9b2adb9 commit 460477f

4 files changed

Lines changed: 9 additions & 15 deletions

File tree

internal-packages/run-engine/src/engine/systems/delayedRunSystem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class DelayedRunSystem {
121121
const env = await this.$.controlPlaneResolver.resolveEnv(run.runtimeEnvironmentId);
122122

123123
if (!env) {
124-
throw new Error(`#enqueueDelayedRun: run not found: ${runId}`);
124+
throw new Error(`#enqueueDelayedRun: environment not found for run: ${runId}`);
125125
}
126126

127127
// Check if delayUntil has been rescheduled to the future (e.g., by debounce)

internal-packages/run-engine/src/engine/systems/dequeueSystem.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ export class DequeueSystem {
772772

773773
if (!env) {
774774
this.$.logger.error("RunEngine.#pendingVersion(): environment not found", { runId });
775+
await this.$.runQueue.acknowledgeMessage(orgId, runId);
775776
return;
776777
}
777778

internal-packages/run-engine/src/engine/systems/ttlSystem.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,7 @@ export class TtlSystem {
101101
prisma
102102
);
103103

104-
const env = await this.$.controlPlaneResolver.resolveEnv(updatedRun.runtimeEnvironmentId);
105-
106-
if (!env) {
107-
this.$.logger.debug("Run cannot be expired because its environment was not found", {
108-
runId,
109-
});
110-
return;
111-
}
112-
113-
await this.$.runQueue.acknowledgeMessage(env.organizationId, runId, {
104+
await this.$.runQueue.acknowledgeMessage(snapshot.organizationId, runId, {
114105
removeFromWorkerQueue: true,
115106
});
116107

@@ -125,9 +116,9 @@ export class TtlSystem {
125116
this.$.eventBus.emit("runExpired", {
126117
run: updatedRun,
127118
time: new Date(),
128-
organization: { id: env.organizationId },
129-
project: { id: env.projectId },
130-
environment: { id: env.id },
119+
organization: { id: snapshot.organizationId },
120+
project: { id: snapshot.projectId },
121+
environment: { id: snapshot.environmentId },
131122
});
132123
});
133124
}

internal-packages/run-engine/src/engine/systems/waitpointSystem.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,9 @@ export class WaitpointSystem {
739739
runId,
740740
runtimeEnvironmentId: run.runtimeEnvironmentId,
741741
});
742-
throw new Error(`continueRunIfUnblocked: run not found: ${runId}`);
742+
throw new Error(
743+
`continueRunIfUnblocked: environment not found: ${run.runtimeEnvironmentId}`
744+
);
743745
}
744746

745747
//4. Continue the run whether it's executing or not

0 commit comments

Comments
 (0)