fix(knowledge): fix document processing stuck in processing state#3857
fix(knowledge): fix document processing stuck in processing state#3857waleedlatif1 merged 5 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Improves connector re-sync reliability by resetting stuck documents back to Cleans up OAuth/credential UX across knowledge connectors and workflows: KB connector flows now use Written by Cursor Bugbot for commit 897b761. Configure here. |
Greptile SummaryThis PR addresses a cluster of related reliability and UX bugs in the knowledge-base document processing pipeline and OAuth credential flow. The changes are well-scoped and the root causes are correctly diagnosed. Core processing fixes (
OAuth credential UX fixes
Key findings:
Confidence Score: 5/5Safe to merge — all remaining findings are P2 style/reliability suggestions that don't affect the primary fix paths. The core document-processing bug (fire-and-forget inline fallback, dead retry code) is correctly fixed. The OAuth false-positive and error-serialization fixes are straightforward and well-tested locally per the PR. The two flagged concerns (partial-failure surfacing and hardcoded preCount) are edge cases that do not block the primary use cases addressed by this PR. No P0/P1 issues found. apps/sim/lib/knowledge/documents/service.ts (partial-failure handling) and apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx (hardcoded preCount) Important Files Changed
Sequence DiagramsequenceDiagram
participant SE as SyncEngine
participant SVC as DocumentService
participant TRG as Trigger.dev
participant DB as Database
participant EMB as EmbeddingAPI
SE->>DB: Find stuck documents (processing > cutoff)
DB-->>SE: stuckDocs[]
SE->>DB: DELETE embeddings WHERE documentId IN stuckDocIds
SE->>DB: UPDATE documents SET status='pending', reset counts
SE->>SVC: processDocumentsWithQueue(stuckDocs)
alt Trigger.dev available
SVC->>TRG: dispatch job (maxAttempts:3)
TRG-->>SVC: enqueued
Note over TRG,DB: Trigger.dev worker picks up job
TRG->>SVC: processDocumentAsync()
SVC->>DB: SET status='processing'
SVC->>EMB: fetch embeddings (60s timeout)
EMB-->>SVC: embeddings[]
SVC->>DB: SET status='completed'
Note over TRG: On error: re-throw → Trigger.dev retries up to 3x
else Inline fallback
SVC->>SVC: await processDocumentAsync()
SVC->>DB: SET status='processing'
SVC->>EMB: fetch embeddings (60s timeout)
EMB-->>SVC: embeddings[]
SVC->>DB: SET status='completed'
Note over SVC: On error: SET status='failed', re-throw → allSettled catches
end
Reviews (2): Last reviewed commit: "upgrade turbo" | Re-trigger Greptile |
.../components/sub-block/components/credential-selector/components/connect-credential-modal.tsx
Outdated
Show resolved
Hide resolved
2852c32 to
b65d041
Compare
b65d041 to
12be44d
Compare
12be44d to
068fa59
Compare
068fa59 to
df314fe
Compare
df314fe to
991e2b8
Compare
991e2b8 to
6c4ac15
Compare
…Copilot OAuth context - Change Promise.all to Promise.allSettled in processDocumentsWithQueue so one failed dispatch doesn't abort the entire batch - Add writeOAuthReturnContext before showing LazyOAuthRequiredModal from Copilot tools so useOAuthReturnForWorkflow can handle the return - Add consumeOAuthReturnContext on modal close to clean up stale context
Pass empty string instead of undefined for connectorProviderId fallback to match the hook's string parameter type.
|
@greptile |
|
@cursor review |
…reshTriggers call Same string narrowing fix as add-connector-modal — pass empty string fallback for providerId.
Summary
Type of Change
Testing
Tested manually
Checklist