fix: address coderabbit review

This commit is contained in:
Rohit Rajan
2026-09-12 00:33:59 +05:30
parent 902593cebc
commit 4a095ea548
2 changed files with 41 additions and 2 deletions
+19 -1
View File
@@ -628,12 +628,30 @@ async function createWorkflowAndStoreMetadata(id: string, userId: string, runSou
jobKey: `${QUEUE_NAMES.EXECUTE_RUN}:${plainRun.runId}`,
});
} catch (queueError: any) {
const finishedAt = new Date().toLocaleString();
await run.update({
status: 'failed',
finishedAt: new Date().toLocaleString(),
finishedAt,
log: `Failed to queue execution job: ${queueError.message}`,
});
try {
serverIo.of('/queued-run').to(`user-${userId}`).emit('run-completed', {
runId: plainRun.runId,
robotMetaId: plainRun.robotMetaId,
robotName: plainRun.name,
status: 'failed',
finishedAt,
runByUserId: plainRun.runByUserId,
runByScheduleId: plainRun.runByScheduleId,
runByAPI: plainRun.runByAPI || false,
browserId: plainRun.browserId,
error: `Failed to queue execution job: ${queueError.message}`,
});
} catch (socketError: any) {
logger.log('warn', `Failed to emit queue failure for API run ${plainRun.runId}: ${socketError.message}`);
}
if (!isDocRobot) {
try {
await destroyRemoteBrowser(browserId, userId);
@@ -123,12 +123,33 @@ async function createWorkflowAndStoreMetadata(id: string, userId: string) {
jobKey: `${QUEUE_NAMES.EXECUTE_RUN}:${plainRun.runId}`,
});
} catch (queueError: any) {
const finishedAt = new Date().toLocaleString();
await run.update({
status: 'failed',
finishedAt: new Date().toLocaleString(),
finishedAt,
log: `Failed to queue scheduled execution job: ${queueError.message}`,
});
const failureSocketData = {
runId: plainRun.runId,
robotMetaId: plainRun.robotMetaId,
robotName: plainRun.name,
status: 'failed',
finishedAt,
runByUserId: plainRun.runByUserId,
runByScheduleId: plainRun.runByScheduleId,
runByAPI: plainRun.runByAPI || false,
browserId: plainRun.browserId,
error: `Failed to queue scheduled execution job: ${queueError.message}`,
};
try {
serverIo.of(browserId).emit('run-completed', failureSocketData);
serverIo.of('/queued-run').to(`user-${userId}`).emit('run-completed', failureSocketData);
} catch (socketError: any) {
logger.log('warn', `Failed to emit queue failure for scheduled run ${plainRun.runId}: ${socketError.message}`);
}
if (!isDocRobot) {
try {
await destroyRemoteBrowser(browserId, userId);