Skip to content

Commit d4d8d9f

Browse files
authored
fix(engine): add additional error logging around triggering runs (#3211)
1 parent 8108683 commit d4d8d9f

File tree

2 files changed

+47
-12
lines changed

2 files changed

+47
-12
lines changed

apps/webapp/app/v3/runEngineHandlers.server.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,16 @@ export function setupBatchQueueCallbacks() {
759759
span.end();
760760
return { success: true as const, runId: result.run.friendlyId };
761761
} else {
762+
logger.error("[BatchQueue] TriggerTaskService returned undefined", {
763+
batchId,
764+
friendlyId,
765+
itemIndex,
766+
task: item.task,
767+
environmentId: meta.environmentId,
768+
attempt,
769+
isFinalAttempt,
770+
});
771+
762772
span.setAttribute("batch.result.error", "TriggerTaskService returned undefined");
763773

764774
// Only create a pre-failed run on the final attempt; otherwise let the retry mechanism handle it
@@ -795,6 +805,18 @@ export function setupBatchQueueCallbacks() {
795805
}
796806
} catch (error) {
797807
const errorMessage = error instanceof Error ? error.message : String(error);
808+
809+
logger.error("[BatchQueue] Failed to trigger batch item", {
810+
batchId,
811+
friendlyId,
812+
itemIndex,
813+
task: item.task,
814+
environmentId: meta.environmentId,
815+
attempt,
816+
isFinalAttempt,
817+
error,
818+
});
819+
798820
span.setAttribute("batch.result.error", errorMessage);
799821
span.recordException(error instanceof Error ? error : new Error(String(error)));
800822

internal-packages/run-engine/src/engine/index.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -769,19 +769,32 @@ export class RunEngine {
769769
}
770770
}
771771
} else {
772-
if (taskRun.ttl) {
773-
await this.ttlSystem.scheduleExpireRun({ runId: taskRun.id, ttl: taskRun.ttl });
774-
}
772+
try {
773+
if (taskRun.ttl) {
774+
await this.ttlSystem.scheduleExpireRun({ runId: taskRun.id, ttl: taskRun.ttl });
775+
}
775776

776-
await this.enqueueSystem.enqueueRun({
777-
run: taskRun,
778-
env: environment,
779-
workerId,
780-
runnerId,
781-
tx: prisma,
782-
skipRunLock: true,
783-
includeTtl: true,
784-
});
777+
await this.enqueueSystem.enqueueRun({
778+
run: taskRun,
779+
env: environment,
780+
workerId,
781+
runnerId,
782+
tx: prisma,
783+
skipRunLock: true,
784+
includeTtl: true,
785+
});
786+
} catch (enqueueError) {
787+
this.logger.error("engine.trigger(): failed to schedule TTL or enqueue run", {
788+
runId: taskRun.id,
789+
friendlyId: taskRun.friendlyId,
790+
taskIdentifier: taskRun.taskIdentifier,
791+
environmentId: environment.id,
792+
ttl: taskRun.ttl,
793+
error: enqueueError,
794+
});
795+
796+
throw enqueueError;
797+
}
785798
}
786799

787800
this.eventBus.emit("runCreated", {

0 commit comments

Comments
 (0)