mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
`on_failure=report_scan_failure` is attached where a scan is enqueued by the socket handler and the watcher, but a scan cron enqueues carried nothing: `CronScheduler.register()` takes no `on_failure` and `CronJob` has no equivalent, so the one scan nobody is watching is also the one whose worker can die without a `scan:done_ko` reaching the clients. RQ reaps the job correctly and moves it to the failed registry, but no callback runs, so the client keeps showing a scan that no longer exists and `/tasks/status` cannot recover it either. Cron now registers a dispatch job for a scan instead. It enqueues the real scan onto the scan queue with the callback attached, mirroring what the socket handler does. The dispatch sits on the low priority queue rather than the scan queue so it fires on the tick instead of waiting behind a scan that is already running, and because it only enqueues, it takes the ordinary task timeout and hands the scan timeout to the scan itself. That last part is a behaviour change: the cron job's own timeout drops from `SCAN_TIMEOUT` to `TASK_TIMEOUT`. The dispatch is left out of the task history, because it carries the scan's own name and finishes in milliseconds, so listing it would show one scheduled rescan as two runs. A dispatch that failed is still listed, since then no scan ran at all. Cron jobs also get an explicit result TTL. `register()` defaults it to RQ's 500 seconds and writes that onto the job, so `job.get_result_ttl()` never fell back to the worker's own 86400 and the Task History panel emptied about eight minutes after each run. Passing `TASK_RESULT_TTL` restores what rq-scheduler gave for free, since it passed no TTL at all. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>