fix(preflight): Correct parameter order and add IP/fingerprint reporting
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -435,29 +435,47 @@ export class TaskWorker {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Report preflight status to worker_registry
|
* Report preflight status to worker_registry
|
||||||
|
* Function signature: update_worker_preflight(worker_id, transport, status, ip, response_ms, error, fingerprint)
|
||||||
*/
|
*/
|
||||||
private async reportPreflightStatus(): Promise<void> {
|
private async reportPreflightStatus(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
// Update worker_registry directly via SQL (more reliable than API)
|
// Update worker_registry directly via SQL (more reliable than API)
|
||||||
|
// CURL preflight - includes IP address
|
||||||
await this.pool.query(`
|
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.workerId,
|
||||||
this.preflightCurlPassed ? 'passed' : 'failed',
|
this.preflightCurlPassed ? 'passed' : 'failed',
|
||||||
|
this.preflightCurlResult?.proxyIp || null,
|
||||||
this.preflightCurlResult?.responseTimeMs || null,
|
this.preflightCurlResult?.responseTimeMs || null,
|
||||||
this.preflightCurlResult?.error || 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(`
|
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.workerId,
|
||||||
this.preflightHttpPassed ? 'passed' : 'failed',
|
this.preflightHttpPassed ? 'passed' : 'failed',
|
||||||
|
this.preflightHttpResult?.proxyIp || null,
|
||||||
this.preflightHttpResult?.responseTimeMs || null,
|
this.preflightHttpResult?.responseTimeMs || null,
|
||||||
this.preflightHttpResult?.error || null,
|
this.preflightHttpResult?.error || null,
|
||||||
|
httpFingerprint ? JSON.stringify(httpFingerprint) : null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
console.log(`[TaskWorker] Preflight status reported to worker_registry`);
|
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) {
|
} catch (err: any) {
|
||||||
// Non-fatal - worker can still function
|
// Non-fatal - worker can still function
|
||||||
console.warn(`[TaskWorker] Could not report preflight status: ${err.message}`);
|
console.warn(`[TaskWorker] Could not report preflight status: ${err.message}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user