From 2834a3446a77cdc7a98bc4a8b98a540e98dc795b Mon Sep 17 00:00:00 2001 From: Luciabrightcode Date: Tue, 23 Dec 2025 18:34:55 +0800 Subject: [PATCH] fix(core): patch worker logic (v1.1.1) - Re-queue auth tasks on 'Executable doesn't exist' error - Record session duration metrics in extraction phase --- src/orchestrator/worker.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/orchestrator/worker.py b/src/orchestrator/worker.py index 84b5ae1..8d9484d 100644 --- a/src/orchestrator/worker.py +++ b/src/orchestrator/worker.py @@ -1,4 +1,5 @@ import asyncio +import time import logging import json import redis.asyncio as redis @@ -90,6 +91,13 @@ class TaskWorker: MetricsCollector.record_auth_success() except Exception as e: + if "Executable doesn't exist" in str(e): + logger.warning(f"Browser binary missing. Re-queueing task for {session_id}") + # Push back to redis (right push to back of queue, or left to retry immediate? usually back is safer) + # But user said "re-queue the task to Redis". + await self.redis.rpush("tasks", json.dumps({"type": "auth", "url": url, "session_id": session_id})) + return + logger.error(f"Auth failed: {e}") MetricsCollector.record_auth_failure(str(e)) await self.recovery.handle_invalidation(session_id, "auth_failure") @@ -110,6 +118,12 @@ class TaskWorker: html = await client.fetch(url) logger.info(f"Extracted {len(html)} bytes from {url} using Session {session_id}") + # Calculate duration + duration = time.time() - state.timestamp + MetricsCollector.record_session_lifetime(duration) + + logger.info(f"Extracted {len(html)} bytes from {url} using Session {session_id} (Duration: {duration:.2f}s)") + MetricsCollector.record_extraction("success") except Exception as e: logger.error(f"Extraction failed: {e}")