feat: rm reset remote browser
This commit is contained in:
@@ -82,41 +82,6 @@ function AddGeneratedFlags(workflow: WorkflowFile) {
|
|||||||
return copy;
|
return copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to reset browser state without creating a new browser
|
|
||||||
*/
|
|
||||||
async function resetBrowserState(browser: RemoteBrowser): Promise<boolean> {
|
|
||||||
try {
|
|
||||||
const currentPage = browser.getCurrentPage();
|
|
||||||
if (!currentPage) {
|
|
||||||
logger.log('error', 'No current page available to reset browser state');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Navigate to blank page to reset state
|
|
||||||
await currentPage.goto('about:blank', { waitUntil: 'networkidle', timeout: 10000 });
|
|
||||||
|
|
||||||
// Clear browser storage
|
|
||||||
await currentPage.evaluate(() => {
|
|
||||||
try {
|
|
||||||
localStorage.clear();
|
|
||||||
sessionStorage.clear();
|
|
||||||
} catch (e) {
|
|
||||||
// Ignore errors in cleanup
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Clear cookies
|
|
||||||
const context = currentPage.context();
|
|
||||||
await context.clearCookies();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (error) {
|
|
||||||
logger.log('error', `Failed to reset browser state`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modified checkAndProcessQueuedRun function - only changes browser reset logic
|
* Modified checkAndProcessQueuedRun function - only changes browser reset logic
|
||||||
*/
|
*/
|
||||||
@@ -137,13 +102,6 @@ async function checkAndProcessQueuedRun(userId: string, browserId: string): Prom
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the browser state before next run
|
|
||||||
const browser = browserPool.getRemoteBrowser(browserId);
|
|
||||||
if (browser) {
|
|
||||||
logger.log('info', `Resetting browser state for browser ${browserId} before next run`);
|
|
||||||
await resetBrowserState(browser);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the queued run to running status
|
// Update the queued run to running status
|
||||||
await queuedRun.update({
|
await queuedRun.update({
|
||||||
status: 'running',
|
status: 'running',
|
||||||
@@ -251,8 +209,6 @@ async function processRunExecution(job: Job<ExecuteRunData>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Reset the browser state before executing this run
|
|
||||||
await resetBrowserState(browser);
|
|
||||||
|
|
||||||
const isRunAborted = async (): Promise<boolean> => {
|
const isRunAborted = async (): Promise<boolean> => {
|
||||||
const currentRun = await Run.findOne({ where: { runId: data.runId } });
|
const currentRun = await Run.findOne({ where: { runId: data.runId } });
|
||||||
|
|||||||
Reference in New Issue
Block a user