temp: rewrite headless config
This commit is contained in:
@@ -464,13 +464,7 @@ async function createWorkflowAndStoreMetadata(id: string, userId: string) {
|
||||
};
|
||||
}
|
||||
|
||||
const browserId = createRemoteBrowserForRun({
|
||||
browser: chromium,
|
||||
launchOptions: {
|
||||
headless: true,
|
||||
proxy: proxyOptions.server ? proxyOptions : undefined,
|
||||
}
|
||||
}, userId);
|
||||
const browserId = createRemoteBrowserForRun(userId);
|
||||
|
||||
const runId = uuid();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
Browser,
|
||||
CDPSession,
|
||||
BrowserContext,
|
||||
chromium,
|
||||
} from 'playwright';
|
||||
import { Socket } from "socket.io";
|
||||
import { PlaywrightBlocker } from '@cliqz/adblocker-playwright';
|
||||
@@ -91,35 +92,39 @@ export class RemoteBrowser {
|
||||
* @param options remote browser options to be used when launching the browser
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public initialize = async (options: RemoteBrowserOptions, userId: string): Promise<void> => {
|
||||
const launchOptions = {
|
||||
public initialize = async (userId: string): Promise<void> => {
|
||||
// const launchOptions = {
|
||||
// headless: true,
|
||||
// proxy: options.launchOptions?.proxy,
|
||||
// chromiumSandbox: false,
|
||||
// args: [
|
||||
// '--no-sandbox',
|
||||
// '--disable-setuid-sandbox',
|
||||
// '--headless=new',
|
||||
// '--disable-gpu',
|
||||
// '--disable-dev-shm-usage',
|
||||
// '--disable-software-rasterizer',
|
||||
// '--in-process-gpu',
|
||||
// '--disable-infobars',
|
||||
// '--single-process',
|
||||
// '--no-zygote',
|
||||
// '--disable-notifications',
|
||||
// '--disable-extensions',
|
||||
// '--disable-background-timer-throttling',
|
||||
// ...(options.launchOptions?.args || [])
|
||||
// ],
|
||||
// env: {
|
||||
// ...process.env,
|
||||
// CHROMIUM_FLAGS: '--disable-gpu --no-sandbox --headless=new'
|
||||
// }
|
||||
// };
|
||||
// console.log('Launch options before:', options.launchOptions);
|
||||
// this.browser = <Browser>(await options.browser.launch(launchOptions));
|
||||
|
||||
// console.log('Launch options after:', options.launchOptions)
|
||||
this.browser = <Browser>(await chromium.launch({
|
||||
headless: true,
|
||||
proxy: options.launchOptions?.proxy,
|
||||
chromiumSandbox: false,
|
||||
args: [
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
'--headless=new',
|
||||
'--disable-gpu',
|
||||
'--disable-dev-shm-usage',
|
||||
'--disable-software-rasterizer',
|
||||
'--in-process-gpu',
|
||||
'--disable-infobars',
|
||||
'--single-process',
|
||||
'--no-zygote',
|
||||
'--disable-notifications',
|
||||
'--disable-extensions',
|
||||
'--disable-background-timer-throttling',
|
||||
...(options.launchOptions?.args || [])
|
||||
],
|
||||
env: {
|
||||
...process.env,
|
||||
CHROMIUM_FLAGS: '--disable-gpu --no-sandbox --headless=new'
|
||||
}
|
||||
};
|
||||
console.log('Launch options before:', options.launchOptions);
|
||||
this.browser = <Browser>(await options.browser.launch(launchOptions));
|
||||
console.log('Launch options after:', options.launchOptions)
|
||||
}));
|
||||
const proxyConfig = await getDecryptedProxyConfig(userId);
|
||||
let proxyOptions: { server: string, username?: string, password?: string } = { server: '' };
|
||||
if (proxyConfig.proxy_url) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import logger from "../logger";
|
||||
* @returns string
|
||||
* @category BrowserManagement-Controller
|
||||
*/
|
||||
export const initializeRemoteBrowserForRecording = (options: RemoteBrowserOptions, userId: string): string => {
|
||||
export const initializeRemoteBrowserForRecording = (userId: string): string => {
|
||||
const id = getActiveBrowserId() || uuid();
|
||||
createSocketConnection(
|
||||
io.of(id),
|
||||
@@ -34,8 +34,7 @@ export const initializeRemoteBrowserForRecording = (options: RemoteBrowserOption
|
||||
} else {
|
||||
const browserSession = new RemoteBrowser(socket);
|
||||
browserSession.interpreter.subscribeToPausing();
|
||||
console.log(`Initialized Browser Config: ${JSON.stringify(options)}`);
|
||||
await browserSession.initialize(options, userId);
|
||||
await browserSession.initialize(userId);
|
||||
await browserSession.registerEditorEvents();
|
||||
await browserSession.subscribeToScreencast();
|
||||
browserPool.addRemoteBrowser(id, browserSession, true);
|
||||
@@ -53,13 +52,13 @@ export const initializeRemoteBrowserForRecording = (options: RemoteBrowserOption
|
||||
* @returns string
|
||||
* @category BrowserManagement-Controller
|
||||
*/
|
||||
export const createRemoteBrowserForRun = (options: RemoteBrowserOptions, userId: string): string => {
|
||||
export const createRemoteBrowserForRun = (userId: string): string => {
|
||||
const id = uuid();
|
||||
createSocketConnectionForRun(
|
||||
io.of(id),
|
||||
async (socket: Socket) => {
|
||||
const browserSession = new RemoteBrowser(socket);
|
||||
await browserSession.initialize(options, userId);
|
||||
await browserSession.initialize(userId);
|
||||
browserPool.addRemoteBrowser(id, browserSession, true);
|
||||
socket.emit('ready-for-run');
|
||||
});
|
||||
|
||||
@@ -56,13 +56,7 @@ router.get('/start', requireSignIn, async (req: AuthenticatedRequest, res: Respo
|
||||
};
|
||||
}
|
||||
|
||||
const id = initializeRemoteBrowserForRecording({
|
||||
browser: chromium,
|
||||
launchOptions: {
|
||||
headless: true,
|
||||
proxy: proxyOptions.server ? proxyOptions : undefined,
|
||||
}
|
||||
}, req.user.id);
|
||||
const id = initializeRemoteBrowserForRecording(req.user.id);
|
||||
console.log('id start:', id);
|
||||
return res.send(id);
|
||||
});
|
||||
@@ -75,13 +69,7 @@ router.post('/start', requireSignIn, (req: AuthenticatedRequest, res:Response) =
|
||||
if (!req.user) {
|
||||
return res.status(401).send('User not authenticated');
|
||||
}
|
||||
const id = initializeRemoteBrowserForRecording({
|
||||
browser: chromium,
|
||||
launchOptions: {
|
||||
headless: true,
|
||||
...req.body,
|
||||
}
|
||||
}, req.user.id);
|
||||
const id = initializeRemoteBrowserForRecording(req.user.id);
|
||||
console.log('id start POST:', id);
|
||||
return res.send(id);
|
||||
});
|
||||
|
||||
@@ -158,13 +158,7 @@ router.put('/runs/:id', requireSignIn, async (req: AuthenticatedRequest, res) =>
|
||||
|
||||
console.log(`Proxy config for run: ${JSON.stringify(proxyOptions)}`)
|
||||
|
||||
const id = createRemoteBrowserForRun({
|
||||
browser: chromium,
|
||||
launchOptions: {
|
||||
headless: true,
|
||||
proxy: proxyOptions.server ? proxyOptions : undefined,
|
||||
}
|
||||
}, req.user.id);
|
||||
const id = createRemoteBrowserForRun(req.user.id);
|
||||
|
||||
const runId = uuid();
|
||||
|
||||
|
||||
@@ -40,13 +40,7 @@ async function createWorkflowAndStoreMetadata(id: string, userId: string) {
|
||||
};
|
||||
}
|
||||
|
||||
const browserId = createRemoteBrowserForRun({
|
||||
browser: chromium,
|
||||
launchOptions: {
|
||||
headless: true,
|
||||
proxy: proxyOptions.server ? proxyOptions : undefined,
|
||||
}
|
||||
}, userId);
|
||||
const browserId = createRemoteBrowserForRun( userId);
|
||||
const runId = uuid();
|
||||
|
||||
const run = await Run.create({
|
||||
|
||||
Reference in New Issue
Block a user