fix: 修复因未捕获的超时错误导致的程序崩溃

This commit is contained in:
foxhui
2026-01-10 18:18:35 +08:00
Unverified
parent 8c80fa5e7a
commit eb1d4ee693
3 changed files with 21 additions and 0 deletions
+8
View File
@@ -337,6 +337,14 @@ export async function waitApiResponse(page, options = {}) {
}
return response;
} catch (e) {
// 检测超时错误,转换为标准错误类型
if (e.name === 'TimeoutError' || e.message?.includes('Timeout')) {
const timeoutSec = Math.round(timeout / 1000);
throw new Error(`API_TIMEOUT: 等待响应超时 (${timeoutSec}秒)`);
}
// 其他错误直接重新抛出(如 PAGE_CLOSED, PAGE_CRASHED 等)
throw e;
} finally {
pageWatcher.cleanup();
}