Skip to content

Commit

Permalink
Interactive execution: run job cleanup regardless of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Brikaa committed Sep 15, 2023
1 parent fe2fc37 commit 040e19f
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions api/src/api/v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,26 @@ router.ws('/connect', async (ws, req) => {
if (job === null) {
job = await get_job(msg);

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();

try {
await job.prime();

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');
Expand Down

0 comments on commit 040e19f

Please sign in to comment.