From 6bcadd9e71fd24062d2c59676fddab12401cf1ca Mon Sep 17 00:00:00 2001 From: Kelly Date: Fri, 12 Dec 2025 00:32:45 -0700 Subject: [PATCH] fix(preflight): Correct parameter order and add IP/fingerprint reporting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix update_worker_preflight call to use correct parameter order: (worker_id, transport, status, ip, response_ms, error, fingerprint) - Add proxyIp to both curl and http preflight reports - Add fingerprint JSONB with timezone, location, and bot detection data - Log HTTP IP and timezone after preflight completes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- backend/src/tasks/task-worker.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/backend/src/tasks/task-worker.ts b/backend/src/tasks/task-worker.ts index 2915981d..c80302de 100644 --- a/backend/src/tasks/task-worker.ts +++ b/backend/src/tasks/task-worker.ts @@ -435,29 +435,47 @@ export class TaskWorker { /** * Report preflight status to worker_registry + * Function signature: update_worker_preflight(worker_id, transport, status, ip, response_ms, error, fingerprint) */ private async reportPreflightStatus(): Promise { try { // Update worker_registry directly via SQL (more reliable than API) + // CURL preflight - includes IP address await this.pool.query(` - SELECT update_worker_preflight($1, 'curl', $2, $3, $4) + SELECT update_worker_preflight($1, 'curl', $2, $3, $4, $5, $6) `, [ this.workerId, this.preflightCurlPassed ? 'passed' : 'failed', + this.preflightCurlResult?.proxyIp || null, this.preflightCurlResult?.responseTimeMs || null, this.preflightCurlResult?.error || null, + null, // No fingerprint for curl ]); + // HTTP preflight - includes IP, fingerprint, and timezone data + const httpFingerprint = this.preflightHttpResult ? { + ...this.preflightHttpResult.fingerprint, + detectedTimezone: (this.preflightHttpResult as any).detectedTimezone, + detectedLocation: (this.preflightHttpResult as any).detectedLocation, + productsReturned: this.preflightHttpResult.productsReturned, + botDetection: (this.preflightHttpResult as any).botDetection, + } : null; + await this.pool.query(` - SELECT update_worker_preflight($1, 'http', $2, $3, $4) + SELECT update_worker_preflight($1, 'http', $2, $3, $4, $5, $6) `, [ this.workerId, this.preflightHttpPassed ? 'passed' : 'failed', + this.preflightHttpResult?.proxyIp || null, this.preflightHttpResult?.responseTimeMs || null, this.preflightHttpResult?.error || null, + httpFingerprint ? JSON.stringify(httpFingerprint) : null, ]); console.log(`[TaskWorker] Preflight status reported to worker_registry`); + if (this.preflightHttpResult?.proxyIp) { + console.log(`[TaskWorker] HTTP IP: ${this.preflightHttpResult.proxyIp}, Timezone: ${(this.preflightHttpResult as any).detectedTimezone || 'unknown'}`); + } } catch (err: any) { // Non-fatal - worker can still function console.warn(`[TaskWorker] Could not report preflight status: ${err.message}`);