fix(knowledge): route connector doc processing through queue instead of fire-and-forget#3754
Conversation
…of fire-and-forget
PR SummaryMedium Risk Overview Stuck document retries are broadened and safer. Retries now include stale Trigger.dev dispatch is optimized and more observable. Sync triggers are tagged, Written by Cursor Bugbot for commit 85d9fcb. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR eliminates the root cause of connector documents getting permanently stuck in
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant S as executeSync
participant DB as Database
participant Q as processDocumentsWithQueue
participant T as Trigger.dev (batchTrigger)
participant R as Redis/In-memory Queue
participant W as processDocumentAsync
S->>DB: fetch existing docs & external docs
S->>DB: addDocument / updateDocument (returns DocumentData)
S->>S: collect into pendingProcessing[]
S->>DB: query stuckDocs (pending/failed/stale-processing, <7 days old)
alt stuckDocs.length > 0
S->>Q: processDocumentsWithQueue(stuckDocs, {})
alt Trigger.dev available
Q->>T: batchTrigger (chunks of 500, idempotency keys)
T-->>W: processDocumentAsync per doc
else fallback
Q->>R: addJob per doc
R-->>W: processDocumentAsync per doc
end
end
alt pendingProcessing.length > 0
S->>Q: processDocumentsWithQueue(pendingProcessing, {})
alt Trigger.dev available
Q->>T: batchTrigger (chunks of 500, idempotency keys)
T-->>W: processDocumentAsync per doc
else fallback
Q->>R: addJob per doc
R-->>W: processDocumentAsync per doc
end
end
S->>DB: completeSyncLog('completed')
S->>DB: count actual docs → lastSyncDocCount
S->>DB: update knowledgeConnector status
Reviews (3): Last reviewed commit: "fix(knowledge): move completeSyncLog aft..." | Re-trigger Greptile |
…ocument processing tasks
|
@greptile |
|
@cursor review |
…rocessingStartedAt in stuck doc query
|
@greptile |
…of fire-and-forget (#3754) * fix(knowledge): route connector doc processing through queue instead of fire-and-forget * fix(knowledge): rename jobIds to batchIds in processDocumentsWithTrigger return type * improvement(knowledge): add Trigger.dev tags for connector sync and document processing tasks * fix(knowledge): move completeSyncLog after doc enqueue, handle NULL processingStartedAt in stuck doc query
Summary
processDocumentAsynccalls were killed when the Trigger.dev sync task exitedprocessDocumentsWithQueue(Trigger.dev → Redis → in-memory) so each doc gets its own task lifecycleprocessDocumentsWithQueuecall per sync instead of N+1 individual callslastSyncDocCountto use actual DB count instead of API response countprocessDocumentsWithTriggerto usebatchTriggerwith idempotency keysretryDocumentProcessingto useprocessDocumentsWithQueueinstead of fire-and-forgetType of Change
Testing
Tested manually
Checklist