@@ -288,11 +288,7 @@ async function processDocumentTags(
288288 return result
289289}
290290
291- /**
292- * Trigger.dev's documented per-call cap for `tasks.batchTrigger` is 1,000
293- * items on SDK 4.3.1+ (we're on 4.4.3). Payloads above this are chunked.
294- * https://trigger.dev/docs/triggering
295- */
291+ /** Per-call cap for `tasks.batchTrigger` on Trigger.dev SDK 4.3.1+. */
296292const TRIGGER_BATCH_SIZE = 1000
297293
298294function buildJobPayload (
@@ -316,12 +312,9 @@ function buildJobPayload(
316312}
317313
318314/**
319- * Dispatches document processing jobs. On Trigger.dev, collapses N runs into
320- * `ceil(N / TRIGGER_BATCH_SIZE)` HTTP calls via `tasks.batchTrigger`. Without
321- * Trigger.dev, falls back to in-process execution via `processDocumentAsync`.
322- *
323- * Throws only when every dispatch fails — partial failures are logged. Stuck
324- * docs left in 'pending' are reaped by the next sync's stuck-doc retry pass.
315+ * Dispatches document processing jobs via Trigger.dev's `batchTrigger` when
316+ * available, or in-process otherwise. Throws only when every dispatch fails;
317+ * partial failures are logged and recovered by the next sync's stuck-doc pass.
325318 */
326319export async function processDocumentsWithQueue (
327320 createdDocuments : DocumentData [ ] ,
@@ -368,12 +361,8 @@ async function dispatchViaBatchTrigger(
368361 chunk . map ( ( payload ) => ( {
369362 payload,
370363 options : {
371- /**
372- * Scoped to (documentId, requestId) so HTTP-level retries inside a
373- * single dispatch don't double-enqueue, while legitimate re-dispatch
374- * (e.g. stuck-doc retry on a later sync) gets a fresh requestId and
375- * is allowed through.
376- */
364+ // Scoped to (documentId, requestId): blocks intra-dispatch retries
365+ // from double-enqueuing; later syncs use a fresh requestId.
377366 idempotencyKey : `doc-process-${ payload . documentId } -${ requestId } ` ,
378367 tags : [
379368 `knowledgeBaseId:${ payload . knowledgeBaseId } ` ,
0 commit comments