mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
close the current page context
This commit is contained in:
parent
617634f2af
commit
4e667c9adb
1 changed files with 7 additions and 9 deletions
|
@ -231,16 +231,14 @@ async function testRemoteBrowser(remoteBrowserURL) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup function to terminate all browser processes and clear cache after each monitoring check.
|
* 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>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async function cleanupBrowser() {
|
async function cleanupBrowser(page) {
|
||||||
if (browser) {
|
if (page) {
|
||||||
const contexts = browser.contexts();
|
await page.context().clearCookies();
|
||||||
for (const context of contexts) {
|
await page.context().clearPermissions();
|
||||||
await context.clearCookies();
|
await page.close();
|
||||||
await context.clearPermissions();
|
|
||||||
await context.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +265,7 @@ class RealBrowserMonitorType extends MonitorType {
|
||||||
path: path.join(Database.screenshotDir, filename),
|
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) {
|
if (res.status() >= 200 && res.status() < 400) {
|
||||||
heartbeat.status = UP;
|
heartbeat.status = UP;
|
||||||
|
|
Loading…
Reference in a new issue