From 515df5d1dc1e9f5daeab480a22863f21eb3eee8d Mon Sep 17 00:00:00 2001 From: JOY Date: Thu, 8 Oct 2026 17:32:16 +0700 Subject: [PATCH] fix(importer): enqueue CLI closes its crawl run The enqueue-only run lingered 'running' until the 6h timeout aborted it; finish it with enqueue stats right after the loop (found during the first production queue run). --- apps/importer/Scripts/enqueue-shopee.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/importer/Scripts/enqueue-shopee.ts b/apps/importer/Scripts/enqueue-shopee.ts index fd938005..20e53802 100644 --- a/apps/importer/Scripts/enqueue-shopee.ts +++ b/apps/importer/Scripts/enqueue-shopee.ts @@ -67,6 +67,10 @@ async function main() { console.log(`[Enqueue] job=${data[0]?.job_id ?? data?.job_id} state=${data[0]?.state ?? data?.state} item=${ids.itemId}`); } } + // Close the run: an enqueue-only run has no worker, so leaving it + // 'running' would linger until the 6h timeout aborts it. + await db.rpc('finish_crawl_run', { p_run_id: runId, p_stats: { enqueued: urls.length - failures, failed: failures } }); + // Non-zero exit when anything failed so automation cannot mistake a // partially-failed or fully-skipped enqueue for success (Codex SHOULD). process.exit(failures > 0 ? 1 : 0);