Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): bound hung delegated stop effects so later runs can start #25675

Mergedjuliusmarmingemerged 7 commits intomain fromrefs/pull/25675/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 112 additions and 1 deletion.

x
0 of 2 viewed, 2 left
24 additions and 1 deletionapps/server/src/orchestration-v2/EffectWorker.tsModified
View file
@@ -562,6 +562,29 @@
}),
​
+// A running effect blocks later work on its thread and its lease is never reclaimed in-process,
+// so a stop that hangs must give up and fall through to the normal retry/fail path.
+const DELEGATED_TASKS_STOP_TIMEOUT = Duration.seconds(30);
+​
+const boundExecution =
+ (effect: EffectOutbox.OrchestrationEffectV2) =>
+ (execution: Effect.Effect<void, OrchestrationEffectExecutionError>) =>
+ effect.request.type === "delegated-tasks.stop"
+ ? execution.pipe(
+ Effect.timeoutOrElse({
+ duration: DELEGATED_TASKS_STOP_TIMEOUT,
+ orElse: () =>
+ Effect.fail(
+ new OrchestrationEffectExecutionError({
+ effectId: effect.id,
+ effectType: effect.request.type,
+ cause: `Timed out after ${Duration.format(DELEGATED_TASKS_STOP_TIMEOUT)}.`,
+ }),
+ ),
+ }),
+ )
+ : execution;
+​
export class OrchestrationEffectWorkerError extends Schema.TaggedError<OrchestrationEffectWorkerError>()(
"OrchestrationEffectWorkerError",