diff --git a/backend/common/models/feature.js b/backend/common/models/feature.js index 3d374a963..57cdc90e4 100644 --- a/backend/common/models/feature.js +++ b/backend/common/models/feature.js @@ -76,9 +76,13 @@ module.exports = function(Feature) { /** Receive the results from the Blast. * @param chunk is a Buffer + * null / undefined indicates child process closed with status 0 (OK) and sent no output. * @param cb is cbWrap of cb passed to dnaSequenceSearch(). */ let searchDataOut = (chunk, cb) => { + if (! chunk) { + cb(null, []); + } else if (chunk.asciiSlice(0,6) === 'Error:') { cb(new Error(chunk.toString())); } else { diff --git a/backend/common/utilities/child-process.js b/backend/common/utilities/child-process.js index 1f22f454f..aff3f56f7 100644 --- a/backend/common/utilities/child-process.js +++ b/backend/common/utilities/child-process.js @@ -17,6 +17,8 @@ var fs = require('fs'); * @param moreParams array of params to pass as command-line params to * child process, after [fileName, useFile] * @param dataOutCb (Buffer chunk, cb) {} + * If child process closes with status 0 (OK) and sent no output, then + * dataOutCb will be called with chunk === null * @param cb response node callback * @param progressive true means pass received data back directly to * dataOutCb, otherwise catenate it and call dataOutCb just once when @@ -138,7 +140,12 @@ exports.childProcess = (scriptName, postData, useFile, fileName, moreParams, dat const message = 'Processed file ' + fileName; if (child.killed) { cb(null, message, true); - } // else check again after timeout + } else { // return empty data result + dataOutCb(null, cb); + /* it would be equivalent to do : cb(null, [], true); + * dataOutCb() may have completion actions. + */ + } } });