From 6a47869578b89212c0e7f2a37d395e804c924d81 Mon Sep 17 00:00:00 2001 From: Omar Brikaa Date: Sat, 16 Sep 2023 21:37:09 +0300 Subject: [PATCH] Comments explaining the try-catch flow --- api/src/api/v2.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/api/v2.js b/api/src/api/v2.js index 1b015b5..032fd51 100644 --- a/api/src/api/v2.js +++ b/api/src/api/v2.js @@ -230,7 +230,7 @@ router.ws('/connect', async (ws, req) => { } finally { await job.cleanup(); } - ws.close(4999, 'Job Completed'); + ws.close(4999, 'Job Completed'); // Will not execute if an error is thrown above } else { ws.close(4000, 'Already Initialized'); } @@ -293,10 +293,10 @@ router.post('/execute', async (req, res) => { return res.status(500).send(); } finally { try { - await job.cleanup(); + await job.cleanup(); // This gets executed before the returns in try/catch } catch (error) { logger.error(`Error cleaning up job: ${job.uuid}:\n${error}`); - return res.status(500).send(); + return res.status(500).send(); // On error, this replaces the return in the outer try-catch } } });