Skip to content

Commit 4afa94d

Browse files
committed
fix(core): propagate navigation errors to prevent silent skips
When a NAV_LOST or missing search component error occurred during company processing, the error was swallowed by the catch block, causing the loop to skip remaining companies without triggering the session retry. Now re-throwing fatal errors to properly trigger the account-level recovery. Also optimized navigateBackToList to skip goBack when already on the list page.
1 parent 0c4037d commit 4afa94d

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/automation/main_flow.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ async function processCompany(webContents, id, company, context, sendLog, emitPr
8585

8686
} catch (procError) {
8787
if (isStopRequested()) return;
88+
89+
if (procError.message.includes('NAV_LOST') || procError.message.includes('找不到搜尋元件')) {
90+
throw procError; // Propagate fatal errors to trigger account-level retry
91+
}
92+
8893
sendLog(`[錯誤] ${code} 異常: ${procError.message},下一間。`, 'error');
8994
}
9095
}

src/automation/voting.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,12 @@ async function navigateBackToList(webContents, sendLog) {
327327
if (clickedBack) {
328328
await waitForNavigation(webContents, 8000);
329329
} else {
330-
sendLog('[導航] 無回列表鈕,嘗試回上頁...');
331-
const waitP = waitForNavigation(webContents, 5000);
332-
webContents.goBack();
333-
await waitP;
330+
if (!(await isAtListPage(webContents))) {
331+
sendLog('[導航] 無回列表鈕,嘗試回上頁...');
332+
const waitP = waitForNavigation(webContents, 5000);
333+
webContents.goBack();
334+
await waitP;
335+
}
334336
}
335337
} catch (e) {
336338
sendLog(`[導航] 返回過程異常: ${e.message}`, 'warning');

0 commit comments

Comments
 (0)