feat: add route to verify is robot is running

This commit is contained in:
Rohit
2025-01-24 12:16:44 +05:30
parent 357488c801
commit 1ec5b3bf7d

View File

@@ -16,6 +16,7 @@ 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());
@@ -33,6 +34,17 @@ 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