fix(utility-agent): Wait for navigation and catch goto error
Build Newspaper Extractor Backend / build-newspaper-backend (push) Failing after 16s Details
Build Newspaper Extractor Frontend / build-newspaper-frontend (push) Failing after 16s Details

This commit is contained in:
Deep Koluguri 2026-07-08 11:02:44 -04:00
parent e4a7d07fdf
commit d57b8cb595
1 changed files with 9 additions and 3 deletions

View File

@ -103,7 +103,10 @@ async function runScrapers(credentials) {
await page.type('#txtLogin', credentials.peoplesGas.username);
await page.type('#txtpwd', credentials.peoplesGas.password);
await page.click('#btnlogin');
await Promise.all([
page.waitForNavigation({ waitUntil: 'domcontentloaded', timeout: 30000 }).catch(()=>null),
page.click('#btnlogin')
]);
console.log('[Scraper] Logged into Peoples Gas. Extracting usage via API...');
@ -121,7 +124,7 @@ async function runScrapers(credentials) {
{ timeout: 30000 }
).catch(() => null);
await page.goto('https://peopleseaccount.com/Portal/Usages.aspx?type=GU', { waitUntil: 'domcontentloaded', timeout: 60000 });
await page.goto('https://peopleseaccount.com/Portal/Usages.aspx?type=GU', { waitUntil: 'domcontentloaded', timeout: 60000 }).catch(e => console.log('[Scraper] PG goto error ignored:', e.message));
let pgUsage = 'N/A';
const apiResponse = await usagePromise;
@ -152,7 +155,10 @@ async function runScrapers(credentials) {
report += `\n_Stats pulled automatically by Utility Agent_`;
console.log('[Scraper] Report generated, sending to WhatsApp...');
console.log('[Scraper] Report generated:');
console.log(report);
console.log('[Scraper] Sending to WhatsApp...');
try {
await fetch(WHATSAPP_GATEWAY_URL, {
method: 'POST',