Interactive execution: run job cleanup regardless of errors

This commit is contained in:
Omar Brikaa 2023-09-15 20:39:15 +03:00
parent fe2fc374aa
commit 040e19fdc2
1 changed files with 18 additions and 11 deletions

View File

@ -210,6 +210,7 @@ router.ws('/connect', async (ws, req) => {
if (job === null) {
job = await get_job(msg);
try {
await job.prime();
ws.send(
@ -221,8 +222,14 @@ router.ws('/connect', async (ws, req) => {
);
await job.execute(event_bus);
} catch (error) {
logger.error(
`Error cleaning up job: ${job.uuid}:\n${error}`
);
throw error;
} finally {
await job.cleanup();
}
ws.close(4999, 'Job Completed');
} else {
ws.close(4000, 'Already Initialized');