MCPcopy Index your code
hub / github.com/simstudioai/sim / markDocumentAsFailedTimeout

Function markDocumentAsFailedTimeout

apps/sim/lib/knowledge/documents/service.ts:1521–1551  ·  view source on GitHub ↗
(
  documentId: string,
  processingStartedAt: Date,
  requestId: string
)

Source from the content-addressed store, hash-verified

1519}
1520
1521export async function markDocumentAsFailedTimeout(
1522 documentId: string,
1523 processingStartedAt: Date,
1524 requestId: string
1525): Promise<{ success: boolean; processingDuration: number }> {
1526 const now = new Date()
1527 const processingDuration = now.getTime() - processingStartedAt.getTime()
1528 const DEAD_PROCESS_THRESHOLD_MS = 600 * 1000 // 10 minutes
1529
1530 if (processingDuration <= DEAD_PROCESS_THRESHOLD_MS) {
1531 throw new Error('Document has not been processing long enough to be considered dead')
1532 }
1533
1534 await db
1535 .update(document)
1536 .set({
1537 processingStatus: 'failed',
1538 processingError: 'Processing timed out. Please retry or re-sync the connector.',
1539 processingCompletedAt: now,
1540 })
1541 .where(eq(document.id, documentId))
1542
1543 logger.info(
1544 `[${requestId}] Marked document ${documentId} as failed due to dead process (processing time: ${Math.round(processingDuration / 1000)}s)`
1545 )
1546
1547 return {
1548 success: true,
1549 processingDuration,
1550 }
1551}
1552
1553export async function retryDocumentProcessing(
1554 knowledgeBaseId: string,

Callers 1

route.tsFile · 0.90

Calls 3

infoMethod · 0.80
setMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected