Skip to content

Commit 27f6a68

Browse files
committed
cleanup redundant code
1 parent f9d4725 commit 27f6a68

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

  • apps/sim/app/api/workflows/[id]/execute

apps/sim/app/api/workflows/[id]/execute/route.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,14 @@ async function handleExecutePost(
12471247
})
12481248

12491249
await handlePostExecutionPauseState({ result, workflowId, executionId, loggingSession })
1250-
const compactTerminalLogs = await compactBlockLogs(result.logs, {
1250+
1251+
/**
1252+
* Compact block logs once and reuse across cancelled/timeout/paused/complete
1253+
* SSE events. Walks all block logs and durably serializes large values to
1254+
* object storage, so doing it twice would double the latency and storage
1255+
* load on the happy path.
1256+
*/
1257+
const compactedBlockLogs = await compactBlockLogs(result.logs, {
12511258
workspaceId,
12521259
workflowId,
12531260
executionId,
@@ -1274,7 +1281,7 @@ async function handleExecutePost(
12741281
data: {
12751282
error: timeoutErrorMessage,
12761283
duration: result.metadata?.duration || 0,
1277-
finalBlockLogs: compactTerminalLogs,
1284+
finalBlockLogs: compactedBlockLogs,
12781285
},
12791286
},
12801287
'error'
@@ -1291,7 +1298,7 @@ async function handleExecutePost(
12911298
workflowId,
12921299
data: {
12931300
duration: result.metadata?.duration || 0,
1294-
finalBlockLogs: compactTerminalLogs,
1301+
finalBlockLogs: compactedBlockLogs,
12951302
},
12961303
},
12971304
'cancelled'
@@ -1319,13 +1326,6 @@ async function handleExecutePost(
13191326
preserveUserFileBase64: true,
13201327
preserveRoot: true,
13211328
})
1322-
const compactFinalBlockLogs = await compactBlockLogs(result.logs, {
1323-
workspaceId,
1324-
workflowId,
1325-
executionId,
1326-
userId: actorUserId,
1327-
requireDurable: true,
1328-
})
13291329

13301330
if (result.status === 'paused') {
13311331
finalMetaStatus = 'complete'
@@ -1340,7 +1340,7 @@ async function handleExecutePost(
13401340
duration: result.metadata?.duration || 0,
13411341
startTime: result.metadata?.startTime || startTime.toISOString(),
13421342
endTime: result.metadata?.endTime || new Date().toISOString(),
1343-
finalBlockLogs: compactFinalBlockLogs,
1343+
finalBlockLogs: compactedBlockLogs,
13441344
},
13451345
},
13461346
'complete'
@@ -1359,7 +1359,7 @@ async function handleExecutePost(
13591359
duration: result.metadata?.duration || 0,
13601360
startTime: result.metadata?.startTime || startTime.toISOString(),
13611361
endTime: result.metadata?.endTime || new Date().toISOString(),
1362-
finalBlockLogs: compactFinalBlockLogs,
1362+
finalBlockLogs: compactedBlockLogs,
13631363
},
13641364
},
13651365
'complete'

0 commit comments

Comments
 (0)