mirror of
https://github.com/getmaxun/maxun.git
synced 2026-10-17 04:30:39 +08:00
fix: address coderabbit review
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user