|
|
|
@ -231,16 +231,14 @@ async function testRemoteBrowser(remoteBrowserURL) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cleanup function to terminate all browser processes and clear cache after each monitoring check.
|
|
|
|
|
* @param {import ("playwright-core").Page} page The page to close
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
*/
|
|
|
|
|
async function cleanupBrowser() {
|
|
|
|
|
if (browser) {
|
|
|
|
|
const contexts = browser.contexts();
|
|
|
|
|
for (const context of contexts) {
|
|
|
|
|
await context.clearCookies();
|
|
|
|
|
await context.clearPermissions();
|
|
|
|
|
await context.close();
|
|
|
|
|
}
|
|
|
|
|
async function cleanupBrowser(page) {
|
|
|
|
|
if (page) {
|
|
|
|
|
await page.context().clearCookies();
|
|
|
|
|
await page.context().clearPermissions();
|
|
|
|
|
await page.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -267,7 +265,7 @@ class RealBrowserMonitorType extends MonitorType {
|
|
|
|
|
path: path.join(Database.screenshotDir, filename),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await cleanupBrowser(); // Ensure cleanup is called after each monitoring check
|
|
|
|
|
await cleanupBrowser(page); // Ensure cleanup is called after each monitoring check
|
|
|
|
|
|
|
|
|
|
if (res.status() >= 200 && res.status() < 400) {
|
|
|
|
|
heartbeat.status = UP;
|
|
|
|
|