Skip to content

Commit 4d76367

Browse files
committed
improve completion tracker callback calling and cleanup
1 parent 00d5428 commit 4d76367

File tree

1 file changed

+7
-3
lines changed
  • internal-packages/run-engine/src/batch-queue

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,16 +687,20 @@ export class BatchQueue {
687687
if (this.completionCallback) {
688688
try {
689689
await this.completionCallback(result);
690+
// Only cleanup if callback succeeded - preserves Redis data for retry on failure
691+
await this.completionTracker.cleanup(batchId);
690692
} catch (error) {
691693
this.logger.error("Error in batch completion callback", {
692694
batchId,
693695
error: error instanceof Error ? error.message : String(error),
694696
});
697+
// Re-throw to preserve Redis data and signal failure to callers
698+
throw error;
695699
}
700+
} else {
701+
// No callback, safe to cleanup
702+
await this.completionTracker.cleanup(batchId);
696703
}
697-
698-
// Clean up Redis keys for this batch
699-
await this.completionTracker.cleanup(batchId);
700704
}
701705

702706
// ============================================================================

0 commit comments

Comments
 (0)