Skip to content

Commit 3bc2515

Browse files
committed
improvement(knowledge): thread requestId through direct dispatch logs
Symmetry polish: dispatchInProcess now includes [requestId] in its error log so direct-mode failures are correlatable the same way trigger-mode failures already are.
1 parent a2cf183 commit 3bc2515

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ export async function processDocumentsWithQueue(
343343

344344
const dispatched = useTrigger
345345
? await dispatchViaBatchTrigger(jobPayloads, requestId)
346-
: await dispatchInProcess(jobPayloads)
346+
: await dispatchInProcess(jobPayloads, requestId)
347347

348348
logger.info(
349349
`[${requestId}] Document dispatch complete: ${dispatched}/${jobPayloads.length} succeeded`
@@ -396,7 +396,10 @@ async function dispatchViaBatchTrigger(
396396
return dispatched
397397
}
398398

399-
async function dispatchInProcess(jobPayloads: DocumentProcessingPayload[]): Promise<number> {
399+
async function dispatchInProcess(
400+
jobPayloads: DocumentProcessingPayload[],
401+
requestId: string
402+
): Promise<number> {
400403
const results = await Promise.allSettled(
401404
jobPayloads.map((p) =>
402405
processDocumentAsync(p.knowledgeBaseId, p.documentId, p.docData, p.processingOptions)
@@ -405,7 +408,8 @@ async function dispatchInProcess(jobPayloads: DocumentProcessingPayload[]): Prom
405408
let dispatched = 0
406409
for (const r of results) {
407410
if (r.status === 'fulfilled') dispatched++
408-
else logger.error('Document dispatch failed', { error: getErrorMessage(r.reason) })
411+
else
412+
logger.error(`[${requestId}] Document dispatch failed`, { error: getErrorMessage(r.reason) })
409413
}
410414
return dispatched
411415
}

0 commit comments

Comments
 (0)