fix: return empty empty str on error

This commit is contained in:
amhsirak
2025-11-17 19:54:28 +05:30
parent 560f5a3300
commit 9b71cfc40c

View File

@@ -1,4 +1,4 @@
import { chromium, Browser, Page, BrowserContext } from 'playwright';
import { chromium, Browser, BrowserContext, Page } from 'playwright';
export interface GetPageSourceOptions {
wait?: number;
@@ -46,9 +46,10 @@ export async function getPageSource(
} catch (error) {
console.error('Error while getting page source: ', error);
return ''; // Explicitly return empty string on error
} finally {
if (page) await page.close();
if (context) await context.close();
if (browser) await browser.close();
}
}
}