fix: create a run handler

This commit is contained in:
karishmas6
2024-10-12 15:52:26 +05:30
parent 4c688fd8fb
commit 08139606cc

View File

@@ -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 } });