Merge pull request #536 from getmaxun/circular
fix: browser pool circular dependency
This commit is contained in:
@@ -118,11 +118,11 @@ export class RemoteBrowser {
|
|||||||
* @param socket socket.io socket instance used to communicate with the client side
|
* @param socket socket.io socket instance used to communicate with the client side
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
public constructor(socket: Socket, userId: string) {
|
public constructor(socket: Socket, userId: string, poolId: string) {
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.interpreter = new WorkflowInterpreter(socket);
|
this.interpreter = new WorkflowInterpreter(socket);
|
||||||
this.generator = new WorkflowGenerator(socket);
|
this.generator = new WorkflowGenerator(socket, poolId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private initializeMemoryManagement(): void {
|
private initializeMemoryManagement(): void {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const initializeRemoteBrowserForRecording = (userId: string): string => {
|
|||||||
remoteBrowser?.updateSocket(socket);
|
remoteBrowser?.updateSocket(socket);
|
||||||
await remoteBrowser?.makeAndEmitScreenshot();
|
await remoteBrowser?.makeAndEmitScreenshot();
|
||||||
} else {
|
} else {
|
||||||
const browserSession = new RemoteBrowser(socket, userId);
|
const browserSession = new RemoteBrowser(socket, userId, id);
|
||||||
browserSession.interpreter.subscribeToPausing();
|
browserSession.interpreter.subscribeToPausing();
|
||||||
await browserSession.initialize(userId);
|
await browserSession.initialize(userId);
|
||||||
await browserSession.registerEditorEvents();
|
await browserSession.registerEditorEvents();
|
||||||
@@ -62,7 +62,7 @@ export const createRemoteBrowserForRun = (userId: string): string => {
|
|||||||
io.of(`/${id}`),
|
io.of(`/${id}`),
|
||||||
async (socket: Socket) => {
|
async (socket: Socket) => {
|
||||||
try {
|
try {
|
||||||
const browserSession = new RemoteBrowser(socket, userId);
|
const browserSession = new RemoteBrowser(socket, userId, id);
|
||||||
await browserSession.initialize(userId);
|
await browserSession.initialize(userId);
|
||||||
browserPool.addRemoteBrowser(id, browserSession, userId, false, "run");
|
browserPool.addRemoteBrowser(id, browserSession, userId, false, "run");
|
||||||
socket.emit('ready-for-run');
|
socket.emit('ready-for-run');
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
import { CustomActions } from "../../../../src/shared/types";
|
import { CustomActions } from "../../../../src/shared/types";
|
||||||
import Robot from "../../models/Robot";
|
import Robot from "../../models/Robot";
|
||||||
import { getBestSelectorForAction } from "../utils";
|
import { getBestSelectorForAction } from "../utils";
|
||||||
import { browserPool } from "../../server";
|
|
||||||
import { uuid } from "uuidv4";
|
import { uuid } from "uuidv4";
|
||||||
import { capture } from "../../utils/analytics"
|
import { capture } from "../../utils/analytics"
|
||||||
import { decrypt, encrypt } from "../../utils/auth";
|
import { decrypt, encrypt } from "../../utils/auth";
|
||||||
@@ -70,14 +69,17 @@ export class WorkflowGenerator {
|
|||||||
|
|
||||||
private paginationMode: boolean = false;
|
private paginationMode: boolean = false;
|
||||||
|
|
||||||
|
private poolId: string | null = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The public constructor of the WorkflowGenerator.
|
* The public constructor of the WorkflowGenerator.
|
||||||
* Takes socket for communication as a parameter and registers some important events on it.
|
* Takes socket for communication as a parameter and registers some important events on it.
|
||||||
* @param socket The socket used to communicate with the client.
|
* @param socket The socket used to communicate with the client.
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
public constructor(socket: Socket) {
|
public constructor(socket: Socket, poolId: string) {
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
|
this.poolId = poolId;
|
||||||
this.registerEventHandlers(socket);
|
this.registerEventHandlers(socket);
|
||||||
this.initializeSocketListeners();
|
this.initializeSocketListeners();
|
||||||
}
|
}
|
||||||
@@ -150,8 +152,7 @@ export class WorkflowGenerator {
|
|||||||
});
|
});
|
||||||
socket.on('activeIndex', (data) => this.generatedData.lastIndex = parseInt(data));
|
socket.on('activeIndex', (data) => this.generatedData.lastIndex = parseInt(data));
|
||||||
socket.on('decision', async ({ pair, actionType, decision, userId }) => {
|
socket.on('decision', async ({ pair, actionType, decision, userId }) => {
|
||||||
const id = browserPool.getActiveBrowserId(userId, "recording");
|
if (this.poolId) {
|
||||||
if (id) {
|
|
||||||
// const activeBrowser = browserPool.getRemoteBrowser(id);
|
// const activeBrowser = browserPool.getRemoteBrowser(id);
|
||||||
// const currentPage = activeBrowser?.getCurrentPage();
|
// const currentPage = activeBrowser?.getCurrentPage();
|
||||||
if (!decision) {
|
if (!decision) {
|
||||||
|
|||||||
Reference in New Issue
Block a user