Skip to content

Commit dc7d876

Browse files
improvement(release): address comments (#4069)
1 parent db23078 commit dc7d876

File tree

3 files changed

+20
-29
lines changed

3 files changed

+20
-29
lines changed

apps/docs/content/docs/en/blocks/human-in-the-loop.mdx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,26 +126,38 @@ Access resume data in downstream blocks using `<blockId.fieldName>`.
126126

127127
- **Stream mode** (`stream: true` on the original execute call) — The resume response streams SSE events with `selectedOutputs` chunks, just like the initial execution.
128128

129-
- **Async mode** (`X-Execution-Mode: async` on the original execute call) — The resume dispatches execution to a background worker and returns immediately with `202`:
129+
- **Async mode** (`X-Execution-Mode: async` on the original execute call) — The resume dispatches execution to a background worker and returns immediately with `202`, including a `jobId` and `statusUrl` for polling:
130130

131131
```json
132132
{
133-
"status": "started",
133+
"success": true,
134+
"async": true,
135+
"jobId": "<jobId>",
134136
"executionId": "<resumeExecutionId>",
135-
"message": "Resume execution started asynchronously."
137+
"message": "Resume execution queued",
138+
"statusUrl": "/api/jobs/<jobId>"
136139
}
137140
```
138141

139142
#### Polling execution status
140143

141-
To check on a paused execution or poll for completion after an async resume:
144+
Poll the `statusUrl` from the async response to check when the resume completes:
145+
146+
```bash
147+
GET /api/jobs/{jobId}
148+
X-API-Key: your-api-key
149+
```
150+
151+
Returns job status and, when completed, the full workflow output.
152+
153+
To check on a paused execution's pause points and resume links:
142154

143155
```bash
144156
GET /api/resume/{workflowId}/{executionId}
145157
X-API-Key: your-api-key
146158
```
147159

148-
Returns the full paused execution detail with all pause points, their statuses, and resume links. Returns `404` when the execution has completed and is no longer paused.
160+
Returns the paused execution detail with all pause points, their statuses, and resume links. Returns `404` when the execution has completed and is no longer paused.
149161
</Tab>
150162
<Tab>
151163
### Webhook

apps/sim/app/api/form/[identifier]/route.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -246,31 +246,10 @@ export async function POST(
246246
),
247247
})
248248

249-
// For forms, we don't stream back - we wait for completion and return success
250-
// Consume the stream to wait for completion
251249
const reader = stream.getReader()
252-
let lastOutput: any = null
253-
254250
try {
255-
while (true) {
256-
const { done, value } = await reader.read()
257-
if (done) break
258-
259-
// Parse SSE data if present
260-
const text = new TextDecoder().decode(value)
261-
const lines = text.split('\n')
262-
for (const line of lines) {
263-
if (line.startsWith('data: ')) {
264-
try {
265-
const data = JSON.parse(line.slice(6))
266-
if (data.type === 'complete' || data.output) {
267-
lastOutput = data.output || data
268-
}
269-
} catch {
270-
// Ignore parse errors
271-
}
272-
}
273-
}
251+
while (!(await reader.read()).done) {
252+
/* drain to let the workflow run to completion */
274253
}
275254
} finally {
276255
reader.releaseLock()

apps/sim/app/api/resume/[workflowId]/[executionId]/[contextId]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export async function POST(
194194
})
195195
}
196196

197-
if (isApiCaller && executionMode !== 'async') {
197+
if (isApiCaller && executionMode === 'sync') {
198198
const result = await PauseResumeManager.startResumeExecution(resumeArgs)
199199

200200
return NextResponse.json({

0 commit comments

Comments
 (0)