diff --git a/api/src/api/v2.js b/api/src/api/v2.js index 9cb5c36..6ac1b94 100644 --- a/api/src/api/v2.js +++ b/api/src/api/v2.js @@ -219,6 +219,7 @@ router.ws('/connect', async (ws, req) => { ); await job.execute_interactive(eventBus); + await job.cleanup(); ws.close(4999, 'Job Completed'); } else { @@ -255,12 +256,6 @@ router.ws('/connect', async (ws, req) => { } }); - ws.on('close', async () => { - if (job !== null) { - await job.cleanup(); - } - }); - setTimeout(() => { //Terminate the socket after 1 second, if not initialized. if (job === null) ws.close(4001, 'Initialization Timeout');