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