chore: lint

This commit is contained in:
amhsirak
2025-01-06 19:34:13 +05:30
parent d25ffe32b8
commit 9cfffd801d

View File

@@ -43,7 +43,6 @@ const SCREENCAST_CONFIG: {
maxQueueSize: 2 maxQueueSize: 2
}; };
/** /**
* This class represents a remote browser instance. * This class represents a remote browser instance.
* It is used to allow a variety of interaction with the Playwright's browser instance. * It is used to allow a variety of interaction with the Playwright's browser instance.
@@ -112,9 +111,9 @@ export class RemoteBrowser {
private startPerformanceReporting() { private startPerformanceReporting() {
setInterval(() => { setInterval(() => {
const report = this.performanceMonitor.getPerformanceReport(); const report = this.performanceMonitor.getPerformanceReport();
console.log('Backend Performance Report:', report); console.log('Backend Performance Report:', report);
}, 5000); }, 5000);
} }
@@ -152,11 +151,11 @@ export class RemoteBrowser {
private async performMemoryCleanup(): Promise<void> { private async performMemoryCleanup(): Promise<void> {
this.screenshotQueue = []; this.screenshotQueue = [];
this.isProcessingScreenshot = false; this.isProcessingScreenshot = false;
if (global.gc) { if (global.gc) {
global.gc(); global.gc();
} }
// Reset CDP session if needed // Reset CDP session if needed
if (this.client) { if (this.client) {
try { try {
@@ -239,7 +238,7 @@ export class RemoteBrowser {
'Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.62 Safari/537.36', 'Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.62 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:118.0) Gecko/20100101 Firefox/118.0', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:118.0) Gecko/20100101 Firefox/118.0',
]; ];
return userAgents[Math.floor(Math.random() * userAgents.length)]; return userAgents[Math.floor(Math.random() * userAgents.length)];
} }
@@ -260,7 +259,7 @@ export class RemoteBrowser {
"--disable-extensions", "--disable-extensions",
"--no-sandbox", "--no-sandbox",
"--disable-dev-shm-usage", "--disable-dev-shm-usage",
], ],
})); }));
const proxyConfig = await getDecryptedProxyConfig(userId); const proxyConfig = await getDecryptedProxyConfig(userId);
let proxyOptions: { server: string, username?: string, password?: string } = { server: '' }; let proxyOptions: { server: string, username?: string, password?: string } = { server: '' };
@@ -333,11 +332,11 @@ export class RemoteBrowser {
this.client = await this.currentPage.context().newCDPSession(this.currentPage); this.client = await this.currentPage.context().newCDPSession(this.currentPage);
await blocker.disableBlockingInPage(this.currentPage); await blocker.disableBlockingInPage(this.currentPage);
console.log('Adblocker initialized'); console.log('Adblocker initialized');
} catch (error: any) { } catch (error: any) {
console.warn('Failed to initialize adblocker, continuing without it:', error.message); console.warn('Failed to initialize adblocker, continuing without it:', error.message);
// Still need to set up the CDP session even if blocker fails // Still need to set up the CDP session even if blocker fails
this.client = await this.currentPage.context().newCDPSession(this.currentPage); this.client = await this.currentPage.context().newCDPSession(this.currentPage);
} }
}; };
/** /**
@@ -657,7 +656,7 @@ export class RemoteBrowser {
const optimizedScreenshot = await this.optimizeScreenshot(payload); const optimizedScreenshot = await this.optimizeScreenshot(payload);
const base64Data = optimizedScreenshot.toString('base64'); const base64Data = optimizedScreenshot.toString('base64');
const dataWithMimeType = `data:image/jpeg;base64,${base64Data}`; const dataWithMimeType = `data:image/jpeg;base64,${base64Data}`;
await new Promise<void>((resolve) => { await new Promise<void>((resolve) => {
this.socket.emit('screencast', dataWithMimeType, () => resolve()); this.socket.emit('screencast', dataWithMimeType, () => resolve());
}); });
@@ -666,7 +665,7 @@ export class RemoteBrowser {
logger.error('Screenshot emission failed:', error); logger.error('Screenshot emission failed:', error);
} finally { } finally {
this.isProcessingScreenshot = false; this.isProcessingScreenshot = false;
// Process next screenshot in queue if any // Process next screenshot in queue if any
if (this.screenshotQueue.length > 0) { if (this.screenshotQueue.length > 0) {
const nextScreenshot = this.screenshotQueue.shift(); const nextScreenshot = this.screenshotQueue.shift();