From cf8533bee1c654b5bd6170eac5be49bcbf9d1d49 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 19 Sep 2019 00:44:02 +0200 Subject: [PATCH] [LocalCommandRunner] run: block a double call of the callback The subprocess event handler fires the "error" and "close" event in case of a failure. Both events would call the given callback, resulting in double processing of the subprocess result downstream. Signed-off-by: Jakob Ackermann --- services/clsi/app/js/LocalCommandRunner.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/clsi/app/js/LocalCommandRunner.js b/services/clsi/app/js/LocalCommandRunner.js index 61ecd88794..67f1a33c91 100644 --- a/services/clsi/app/js/LocalCommandRunner.js +++ b/services/clsi/app/js/LocalCommandRunner.js @@ -15,6 +15,7 @@ */ let CommandRunner const { spawn } = require('child_process') +const _ = require('underscore') const logger = require('logger-sharelatex') logger.info('using standard command runner') @@ -24,6 +25,8 @@ module.exports = CommandRunner = { let key, value if (callback == null) { callback = function(error) {} + } else { + callback = _.once(callback) } command = Array.from(command).map(arg => arg.toString().replace('$COMPILE_DIR', directory)