From 08139606ccf2326d8b78530d66a6c381d18c0355 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 12 Oct 2024 15:52:26 +0530 Subject: [PATCH] fix: create a run handler --- server/src/api/record.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/server/src/api/record.ts b/server/src/api/record.ts index ac3c06e1..192041db 100644 --- a/server/src/api/record.ts +++ b/server/src/api/record.ts @@ -170,6 +170,25 @@ router.get("/robots/:id/runs/:runId", requireAPIKey, async (req: Request, res: R } }); +async function readyForRunHandler(browserId: string, id: string) { + try { + const interpretation = await executeRun(id); + + if (interpretation) { + logger.log('info', `Interpretation of ${id} succeeded`); + } else { + logger.log('error', `Interpretation of ${id} failed`); + await destroyRemoteBrowser(browserId); + } + + resetRecordingState(browserId, id); + + } catch (error: any) { + logger.error(`Error during readyForRunHandler: ${error.message}`); + await destroyRemoteBrowser(browserId); + } + } + async function executeRun(id: string) { try { const run = await Run.findOne({ where: { runId: id } });