Skip to content

Commit af162f8

Browse files
fix(api): bridge resume queue visibility lag
1 parent 460a11e commit af162f8

2 files changed

Lines changed: 53 additions & 1 deletion

File tree

apps/sim/lib/workflows/executor/execution-status.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,35 @@ describe('getWorkflowExecutionStatus queue projection', () => {
100100
})
101101
})
102102

103+
it('keeps an active resume queued while its background job is not yet visible', async () => {
104+
queueTableRows(schemaMock.workflowExecutionLogs, [
105+
{
106+
executionId: 'execution-1',
107+
workflowId: 'workflow-1',
108+
status: 'paused',
109+
trigger: 'api',
110+
},
111+
])
112+
queueTableRows(schemaMock.resumeQueue, [
113+
{
114+
id: 'resume-entry-1',
115+
queuedAt: new Date('2026-08-05T12:00:00.000Z'),
116+
claimedAt: new Date('2026-08-05T12:00:01.000Z'),
117+
},
118+
])
119+
mockGetJob.mockResolvedValueOnce(null)
120+
121+
const status = await getWorkflowExecutionStatus(input)
122+
123+
expect(status).toMatchObject({
124+
executionId: 'execution-1',
125+
status: 'queued',
126+
trigger: 'api',
127+
startedAt: '2026-08-05T12:00:01.000Z',
128+
paused: null,
129+
})
130+
})
131+
103132
it('returns completed queue output when requested', async () => {
104133
mockGetJob.mockResolvedValueOnce({
105134
status: 'completed',

apps/sim/lib/workflows/executor/execution-status.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ export async function getWorkflowExecutionStatus(
155155
.limit(1)
156156

157157
const [activeResume] = await db
158-
.select({ id: resumeQueue.id })
158+
.select({
159+
id: resumeQueue.id,
160+
queuedAt: resumeQueue.queuedAt,
161+
claimedAt: resumeQueue.claimedAt,
162+
})
159163
.from(resumeQueue)
160164
.where(
161165
and(
@@ -180,6 +184,25 @@ export async function getWorkflowExecutionStatus(
180184
}
181185
}
182186

187+
if (activeResume && logRow) {
188+
const startedAt = activeResume.claimedAt ?? activeResume.queuedAt
189+
return {
190+
executionId,
191+
workflowId,
192+
status: 'queued',
193+
trigger: logRow.trigger,
194+
level: 'info',
195+
startedAt: startedAt.toISOString(),
196+
endedAt: null,
197+
totalDurationMs: null,
198+
paused: null,
199+
cost: null,
200+
error: null,
201+
finalOutput: null,
202+
blockOutputs: null,
203+
}
204+
}
205+
183206
if (!logRow) return null
184207

185208
const [pausedRow] = await db

0 commit comments

Comments
 (0)