Skip to content

Commit e7b216b

Browse files
waleedlatif1claude
andcommitted
fix(processing): guard completionPromise as write-once (singleton promise)
Prevent concurrent safeComplete* calls from overwriting completionPromise with a no-op. The guard now lives at the assignment site — if a completion is already in-flight, return its promise instead of starting a new one. This ensures waitForCompletion() always awaits the real work. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4fae73b commit e7b216b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

apps/sim/lib/logs/execution/logging-session.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ export class LoggingSession {
689689
}
690690

691691
async safeComplete(params: SessionCompleteParams = {}): Promise<void> {
692+
if (this.completionPromise) return this.completionPromise
692693
this.completionPromise = this._safeCompleteImpl(params)
693694
return this.completionPromise
694695
}
@@ -713,6 +714,7 @@ export class LoggingSession {
713714
}
714715

715716
async safeCompleteWithError(params?: SessionErrorCompleteParams): Promise<void> {
717+
if (this.completionPromise) return this.completionPromise
716718
this.completionPromise = this._safeCompleteWithErrorImpl(params)
717719
return this.completionPromise
718720
}
@@ -739,6 +741,7 @@ export class LoggingSession {
739741
}
740742

741743
async safeCompleteWithCancellation(params?: SessionCancelledParams): Promise<void> {
744+
if (this.completionPromise) return this.completionPromise
742745
this.completionPromise = this._safeCompleteWithCancellationImpl(params)
743746
return this.completionPromise
744747
}
@@ -764,6 +767,7 @@ export class LoggingSession {
764767
}
765768

766769
async safeCompleteWithPause(params?: SessionPausedParams): Promise<void> {
770+
if (this.completionPromise) return this.completionPromise
767771
this.completionPromise = this._safeCompleteWithPauseImpl(params)
768772
return this.completionPromise
769773
}

0 commit comments

Comments
 (0)