From 5a47b1a26898cf8ef963439d3da98fc91f4ded17 Mon Sep 17 00:00:00 2001 From: Steven Weaver Date: Fri, 3 Nov 2023 13:06:41 -0400 Subject: [PATCH 1/2] closes veg/hyphy#1651 Fix EAGAIN error handling in JobStatus spawning process --- lib/jobstatus.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/jobstatus.js b/lib/jobstatus.js index 5d96072..f276a41 100644 --- a/lib/jobstatus.js +++ b/lib/jobstatus.js @@ -49,6 +49,12 @@ JobStatus.prototype.returnJobStatus = function(job_id, callback) { // If the job exists, check and return its status. If it is complete, stop // the metronome. + qstat.on('error', function(err) { + self.error = "Error spawning qstat: " + err.message; + callback(self.error, self.status); // Pass the error to the callback + }); + + qstat.stdout.on("data", function(data) { var job_status = null; @@ -143,6 +149,11 @@ JobStatus.prototype.fullJobInfo = function(callback) { var qstat = spawn("qstat", ["-f", self.job_id]); + qstat.on('error', function(err) { + self.error = "Error spawning qstat: " + err.message; + callback(self.error, self.status); // Pass the error to the callback + }); + qstat.stdout.on("data", function(data) { var job_status = translateQstat(data.toString()); self.callback(self.error, job_status); From b84fcd197c01b90e81e02e5a24210df592670be2 Mon Sep 17 00:00:00 2001 From: Steven Weaver Date: Fri, 3 Nov 2023 13:18:17 -0400 Subject: [PATCH 2/2] version bump --- lib/jobstatus.js | 16 ++-------------- package.json | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/jobstatus.js b/lib/jobstatus.js index f276a41..da90f39 100644 --- a/lib/jobstatus.js +++ b/lib/jobstatus.js @@ -4,7 +4,6 @@ const spawn = require("child_process").spawn, logger = require("./logger").logger; var JobStatus = function(job_id) { - var self = this; self.metronome = 0; @@ -21,12 +20,10 @@ var JobStatus = function(job_id) { W: "waiting", S: "suspended" }; - }; // Define the status-returning function. JobStatus.prototype.returnJobStatus = function(job_id, callback) { - var self = this; self.callback = callback; self.job_id = job_id; @@ -49,14 +46,12 @@ JobStatus.prototype.returnJobStatus = function(job_id, callback) { // If the job exists, check and return its status. If it is complete, stop // the metronome. - qstat.on('error', function(err) { + qstat.on("error", function(err) { self.error = "Error spawning qstat: " + err.message; callback(self.error, self.status); // Pass the error to the callback }); - qstat.stdout.on("data", function(data) { - var job_status = null; var job_ctime = null; var job_stime = null; @@ -108,7 +103,6 @@ JobStatus.prototype.returnJobStatus = function(job_id, callback) { // If the job doesn't exist, return that information and stop the metronome. // If some other error occurs, say so. qstat.stderr.on("data", function(data) { - logger.info(self.job_id + " " + data); var doesnt_exist = @@ -121,13 +115,10 @@ JobStatus.prototype.returnJobStatus = function(job_id, callback) { } self.callback(self.error, self.status); - }); - }; JobStatus.prototype.fullJobInfo = function(callback) { - var self = this; self.callback = callback; @@ -149,7 +140,7 @@ JobStatus.prototype.fullJobInfo = function(callback) { var qstat = spawn("qstat", ["-f", self.job_id]); - qstat.on('error', function(err) { + qstat.on("error", function(err) { self.error = "Error spawning qstat: " + err.message; callback(self.error, self.status); // Pass the error to the callback }); @@ -166,11 +157,9 @@ JobStatus.prototype.fullJobInfo = function(callback) { self.error = self.job_id + " no longer exists in the queue"; self.callback(self.error, ""); }); - }; JobStatus.prototype.watch = function(callback) { - var self = this; var metronome = new setInterval( @@ -181,7 +170,6 @@ JobStatus.prototype.watch = function(callback) { ); return metronome; - }; exports.JobStatus = JobStatus; diff --git a/package.json b/package.json index f165a9e..ca935dc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "datamonkey-js-server", "description": "", - "version": "2.4.0", + "version": "2.4.1", "engines": { "node": ">=13" },