From 712b12805a9b834c8702bf167c0ab5b666bd9ceb Mon Sep 17 00:00:00 2001 From: mikeTWC1984 Date: Sun, 3 Mar 2024 23:17:22 -0500 Subject: [PATCH] WF plug - exit on unexpected error --- bin/workflow.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/workflow.js b/bin/workflow.js index 9d5974f..3fcefd8 100644 --- a/bin/workflow.js +++ b/bin/workflow.js @@ -6,6 +6,7 @@ const request = new PixlRequest(); const he = require('he'); const {EOL} = require('os') const JSONStream = require('pixl-json-stream'); +const { profileEnd } = require('console'); let bullet = '>' // '⬤' @@ -381,6 +382,7 @@ stream.on('json', function (job) { }) function getNiceTitle(job, id) { + if(!job) return '' let title = ' ' + job.seq + ' :: ' + (job.title || 'Unknown') + '' // if(id) title = `${id} :: ${title} ` // if(job.arg) title = title + ' :: ' + job.arg @@ -406,7 +408,7 @@ stream.on('json', function (job) { jobStatus[key].start, niceInterval(jobStatus[key].elapsed), getNiceStatus(jobStatus[key]), // status - key === jobStatus[key].event ? '' : ``, + key === jobStatus[key].event ? '' : ``, //jobStatus[key].code ? `${he.encode(jobStatus[key].description)}`.substring(0,120) : '' `${he.encode(jobStatus[key].description)}`.substring(0, 120) @@ -428,6 +430,10 @@ stream.on('json', function (job) { }; - poll().catch(e => stream.write({ complete: 1, code: 1, description: e.message })); + poll().catch(e => { + stream.write({ complete: 1, code: 1, description: 'Plugin crashed: ' + e.message }) + //if(process.connected) process.disconnect() + process.exit(1) + }); }); \ No newline at end of file