Revert "fix: prevent page reload on run trigger to open remote browser"
This commit is contained in:
@@ -15,8 +15,6 @@ interface BrowserPoolInfo {
|
||||
* @default false
|
||||
*/
|
||||
active: boolean,
|
||||
|
||||
isRobotRun?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,29 +46,17 @@ export class BrowserPool {
|
||||
* @param browser remote browser instance
|
||||
* @param active states if the browser's instance is being actively used
|
||||
*/
|
||||
public addRemoteBrowser = (id: string, browser: RemoteBrowser, active: boolean = false, isRobotRun: boolean = false): void => {
|
||||
public addRemoteBrowser = (id: string, browser: RemoteBrowser, active: boolean = false): void => {
|
||||
this.pool = {
|
||||
...this.pool,
|
||||
[id]: {
|
||||
browser,
|
||||
active,
|
||||
isRobotRun
|
||||
},
|
||||
}
|
||||
logger.log('debug', `Remote browser with id: ${id} added to the pool`);
|
||||
};
|
||||
|
||||
public hasActiveRobotRun(): boolean {
|
||||
return Object.values(this.pool).some(info => info.isRobotRun);
|
||||
}
|
||||
|
||||
public clearRobotRunState(id: string): void {
|
||||
if (this.pool[id]) {
|
||||
this.pool[id].isRobotRun = false;
|
||||
logger.log('debug', `Robot run state cleared for browser ${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the remote browser instance from the pool.
|
||||
* @param id remote browser instance's id
|
||||
@@ -81,8 +67,6 @@ export class BrowserPool {
|
||||
logger.log('warn', `Remote browser with id: ${id} does not exist in the pool`);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.clearRobotRunState(id);
|
||||
delete (this.pool[id]);
|
||||
logger.log('debug', `Remote browser with id: ${id} deleted from the pool`);
|
||||
return true;
|
||||
|
||||
@@ -59,7 +59,7 @@ export const createRemoteBrowserForRun = (userId: string): string => {
|
||||
async (socket: Socket) => {
|
||||
const browserSession = new RemoteBrowser(socket);
|
||||
await browserSession.initialize(userId);
|
||||
browserPool.addRemoteBrowser(id, browserSession, true, true);
|
||||
browserPool.addRemoteBrowser(id, browserSession, true);
|
||||
socket.emit('ready-for-run');
|
||||
});
|
||||
return id;
|
||||
|
||||
@@ -16,7 +16,6 @@ import stealthPlugin from 'puppeteer-extra-plugin-stealth';
|
||||
import logger from "../logger";
|
||||
import { getDecryptedProxyConfig } from './proxy';
|
||||
import { requireSignIn } from '../middlewares/auth';
|
||||
import { browserPool } from '../server';
|
||||
|
||||
export const router = Router();
|
||||
chromium.use(stealthPlugin());
|
||||
@@ -34,17 +33,6 @@ router.all('/', requireSignIn, (req, res, next) => {
|
||||
next() // pass control to the next handler
|
||||
})
|
||||
|
||||
router.use('/', requireSignIn, (req: AuthenticatedRequest, res: Response, next) => {
|
||||
if (browserPool.hasActiveRobotRun()) {
|
||||
logger.log('debug', 'Preventing browser initialization - robot run in progress');
|
||||
return res.status(403).json({
|
||||
error: 'Cannot initialize recording browser while a robot run is in progress'
|
||||
});
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* GET endpoint for starting the remote browser recording session.
|
||||
* returns session's id
|
||||
|
||||
@@ -332,8 +332,6 @@ export class WorkflowInterpreter {
|
||||
}, {})
|
||||
}
|
||||
|
||||
this.socket.emit('run-completed', "success");
|
||||
|
||||
logger.log('debug', `Interpretation finished`);
|
||||
this.clearState();
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user