Skip to content

Commit 41e1c9c

Browse files
committed
fix status check
1 parent 8ee4c59 commit 41e1c9c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

apps/sim/lib/core/workspace-dispatch/memory-store.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ export class MemoryWorkspaceDispatchStorage implements WorkspaceDispatchStorageA
114114
return Array.from(this.jobs.values()).filter((record) => statuses.includes(record.status))
115115
}
116116

117+
private static readonly TERMINAL_STATUSES = new Set(['completed', 'failed'])
118+
117119
async updateDispatchJobRecord(
118120
jobId: string,
119121
updater: (record: WorkspaceDispatchJobRecord) => WorkspaceDispatchJobRecord
@@ -124,6 +126,13 @@ export class MemoryWorkspaceDispatchStorage implements WorkspaceDispatchStorageA
124126
}
125127

126128
const updated = updater(current)
129+
if (
130+
MemoryWorkspaceDispatchStorage.TERMINAL_STATUSES.has(current.status) &&
131+
!MemoryWorkspaceDispatchStorage.TERMINAL_STATUSES.has(updated.status)
132+
) {
133+
return current
134+
}
135+
127136
this.jobs.set(jobId, updated)
128137
return updated
129138
}

apps/sim/lib/core/workspace-dispatch/redis-store.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ export class RedisWorkspaceDispatchStorage implements WorkspaceDispatchStorageAd
233233
return jobs
234234
}
235235

236+
private static readonly TERMINAL_STATUSES = new Set(['completed', 'failed'])
237+
236238
async updateDispatchJobRecord(
237239
jobId: string,
238240
updater: (record: WorkspaceDispatchJobRecord) => WorkspaceDispatchJobRecord
@@ -243,6 +245,13 @@ export class RedisWorkspaceDispatchStorage implements WorkspaceDispatchStorageAd
243245
}
244246

245247
const updated = updater(current)
248+
if (
249+
RedisWorkspaceDispatchStorage.TERMINAL_STATUSES.has(current.status) &&
250+
!RedisWorkspaceDispatchStorage.TERMINAL_STATUSES.has(updated.status)
251+
) {
252+
return current
253+
}
254+
246255
await this.saveDispatchJob(updated)
247256
return updated
248257
}

0 commit comments

Comments
 (0)