From bc5ad6dbdb45f0754ff258a8af505e5677f8f802 Mon Sep 17 00:00:00 2001 From: Randall Stillwell Date: Fri, 17 Apr 2026 14:46:16 -0500 Subject: [PATCH] Fix FTP connection timeout: add 15s timeout and accept self-signed certs The FTP client had no timeout, causing Vercel function timeouts on connection issues. Added a 15-second timeout to both pollFtp and testFtpConnection. Also added secureOptions.rejectUnauthorized=false to prevent TLS failures with self-signed or non-standard certificates. Made-with: Cursor --- src/lib/ftp-watcher.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/ftp-watcher.ts b/src/lib/ftp-watcher.ts index effab2e..a8bd70d 100644 --- a/src/lib/ftp-watcher.ts +++ b/src/lib/ftp-watcher.ts @@ -38,7 +38,7 @@ export async function pollFtp(): Promise<{ processed: number; skipped: number; e return { processed: 0, skipped: 0, error: "FTP not configured" }; } - const client = new Client(); + const client = new Client(15_000); let processed = 0; let skipped = 0; @@ -49,6 +49,7 @@ export async function pollFtp(): Promise<{ processed: number; skipped: number; e user: settings.ftpUser, password: settings.ftpPass, secure: settings.ftpTls, + secureOptions: { rejectUnauthorized: false }, }); log(`Connected to ${settings.ftpHost}:${settings.ftpPort}`); @@ -126,7 +127,7 @@ export async function testFtpConnection(config: { tls: boolean; incomingDir: string; }): Promise<{ ok: boolean; files?: number; error?: string }> { - const client = new Client(); + const client = new Client(15_000); try { await client.access({ host: config.host, @@ -134,6 +135,7 @@ export async function testFtpConnection(config: { user: config.user, password: config.pass, secure: config.tls, + secureOptions: { rejectUnauthorized: false }, }); const files = await client.list(config.incomingDir);