Skip to content

Commit b98429d

Browse files
committed
improvement(knowledge): trim verbose comments
Tightens TSDoc on processDocumentsWithQueue, TRIGGER_BATCH_SIZE, checkSyncLiveness, and the idempotency-key inline comment.
1 parent 3bc2515 commit b98429d

2 files changed

Lines changed: 7 additions & 21 deletions

File tree

apps/sim/lib/knowledge/connectors/sync-engine.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ type DocOp =
5858
| { type: 'add'; extDoc: ExternalDocument }
5959
| { type: 'update'; existingId: string; extDoc: ExternalDocument }
6060

61-
/**
62-
* Combined liveness check used between batches. One JOIN query checks both
63-
* connector and knowledge base state in a single roundtrip.
64-
*/
61+
/** Single-roundtrip liveness check used between batches. */
6562
async function checkSyncLiveness(
6663
connectorId: string,
6764
knowledgeBaseId: string

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

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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+. */
296292
const TRIGGER_BATCH_SIZE = 1000
297293

298294
function 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
*/
326319
export 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

Comments
 (0)