Skip to content

Commit a2cf183

Browse files
committed
improvement(knowledge): log Trigger.dev batchIds for audit trail
tasks.batchTrigger returns a batchId per call. Collecting and logging them after dispatch makes it possible to look up or cancel batches in the Trigger.dev dashboard when investigating stuck or missing documents.
1 parent b783c90 commit a2cf183

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

apps/sim/lib/knowledge/documents/service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,11 @@ async function dispatchViaBatchTrigger(
359359
requestId: string
360360
): Promise<number> {
361361
let dispatched = 0
362+
const batchIds: string[] = []
362363
for (let i = 0; i < jobPayloads.length; i += TRIGGER_BATCH_SIZE) {
363364
const chunk = jobPayloads.slice(i, i + TRIGGER_BATCH_SIZE)
364365
try {
365-
await tasks.batchTrigger<typeof processDocumentTask>(
366+
const result = await tasks.batchTrigger<typeof processDocumentTask>(
366367
'knowledge-process-document',
367368
chunk.map((payload) => ({
368369
payload,
@@ -381,13 +382,17 @@ async function dispatchViaBatchTrigger(
381382
},
382383
}))
383384
)
385+
batchIds.push(result.batchId)
384386
dispatched += chunk.length
385387
} catch (error) {
386388
logger.error(`[${requestId}] Failed to batchTrigger ${chunk.length} document jobs`, {
387389
error: getErrorMessage(error),
388390
})
389391
}
390392
}
393+
if (batchIds.length > 0) {
394+
logger.info(`[${requestId}] Trigger.dev batches dispatched`, { batchIds })
395+
}
391396
return dispatched
392397
}
393398

0 commit comments

Comments
 (0)