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) { if (job === null) {
job = await get_job(msg); job = await get_job(msg);
await job.prime(); try {
await job.prime();
ws.send( ws.send(
JSON.stringify({ JSON.stringify({
type: 'runtime', type: 'runtime',
language: job.runtime.language, language: job.runtime.language,
version: job.runtime.version.raw, version: job.runtime.version.raw,
}) })
); );
await job.execute(event_bus);
await job.cleanup();
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'); ws.close(4999, 'Job Completed');
} else { } else {
ws.close(4000, 'Already Initialized'); ws.close(4000, 'Already Initialized');