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,19 +210,26 @@ router.ws('/connect', async (ws, req) => {
if (job === null) {
job = await get_job(msg);
await job.prime();
try {
await job.prime();
ws.send(
JSON.stringify({
type: 'runtime',
language: job.runtime.language,
version: job.runtime.version.raw,
})
);
await job.execute(event_bus);
await job.cleanup();
ws.send(
JSON.stringify({
type: 'runtime',
language: job.runtime.language,
version: job.runtime.version.raw,
})
);
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');