Skip to content

Commit 8902752

Browse files
committed
improvement(timeouts): files/base64 should use max timeouts
1 parent e321f88 commit 8902752

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

apps/sim/app/api/jobs/[jobId]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export async function GET(
7676
}
7777

7878
if (job.status === JOB_STATUS.PROCESSING || job.status === JOB_STATUS.PENDING) {
79-
response.estimatedDuration = 180000
79+
response.estimatedDuration = 300000
8080
}
8181

8282
return NextResponse.json(response)

apps/sim/lib/knowledge/documents/document-processor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { mistralParserTool } from '@/tools/mistral/parser'
1414
const logger = createLogger('DocumentProcessor')
1515

1616
const TIMEOUTS = {
17-
FILE_DOWNLOAD: 180000,
17+
FILE_DOWNLOAD: 600000,
1818
MISTRAL_OCR_API: 120000,
1919
} as const
2020

apps/sim/lib/uploads/utils/file-utils.server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use server'
22

33
import type { Logger } from '@sim/logger'
4+
import { getMaxExecutionTimeout } from '@/lib/core/execution-limits'
45
import {
56
secureFetchWithPinnedIP,
67
validateUrlWithDNS,
@@ -135,7 +136,10 @@ export async function resolveFileInputToUrl(
135136
* For internal URLs, uses direct storage access (server-side only)
136137
* For external URLs, validates DNS/SSRF and uses secure fetch with IP pinning
137138
*/
138-
export async function downloadFileFromUrl(fileUrl: string, timeoutMs = 180000): Promise<Buffer> {
139+
export async function downloadFileFromUrl(
140+
fileUrl: string,
141+
timeoutMs = getMaxExecutionTimeout()
142+
): Promise<Buffer> {
139143
const { parseInternalFileUrl } = await import('./file-utils')
140144

141145
if (isInternalFileUrl(fileUrl)) {

apps/sim/lib/uploads/utils/user-file-base64.server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import type { Logger } from '@sim/logger'
22
import { createLogger } from '@sim/logger'
33
import { getRedisClient } from '@/lib/core/config/redis'
4+
import { getMaxExecutionTimeout } from '@/lib/core/execution-limits'
45
import { isUserFileWithMetadata } from '@/lib/core/utils/user-file'
56
import { bufferToBase64 } from '@/lib/uploads/utils/file-utils'
67
import { downloadFileFromStorage, downloadFileFromUrl } from '@/lib/uploads/utils/file-utils.server'
78
import type { UserFile } from '@/executor/types'
89

910
const DEFAULT_MAX_BASE64_BYTES = 10 * 1024 * 1024
10-
const DEFAULT_TIMEOUT_MS = 180000
11+
const DEFAULT_TIMEOUT_MS = getMaxExecutionTimeout()
1112
const DEFAULT_CACHE_TTL_SECONDS = 300
1213
const REDIS_KEY_PREFIX = 'user-file:base64:'
1314

0 commit comments

Comments
 (0)