]> git.cworth.org Git - zombocom-ai/commitdiff
Add exception handling to execution of image generation script
authorCarl Worth <cworth@cworth.org>
Thu, 8 Dec 2022 01:05:58 +0000 (17:05 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 8 Dec 2022 01:05:58 +0000 (17:05 -0800)
So that if the script fails for some reason, the server doesn't crash.

index.js

index ba01d67ffbe60b85403b5026e514b51f34d9a389..638c59dc6543fbab851e179d9b59b74aa123c51c 100644 (file)
--- a/index.js
+++ b/index.js
@@ -84,7 +84,11 @@ io.on('connection', (socket) => {
             child.stderr.on('data', (data) => {
                 console.log("Error occurred during generate-image: " + data);
             });
-            const { stdout, stderr } = await promise;
+            try {
+                const { stdout, stderr } = await promise;
+            } catch(e) {
+                console.error(e);
+            }
             socket.emit('generation-done');
         }
         generate_image(request['code'], request['prompt']);