From d0bbe8beaeaa847117594ba37cf73fa920c9c626 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Wed, 21 Jun 2017 15:18:36 +0100 Subject: [PATCH] If optipng is sigkilled by timeout, then ignore that error --- services/filestore/app/coffee/ImageOptimiser.coffee | 4 +++- .../test/unit/coffee/ImageOptimiserTests.coffee | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/services/filestore/app/coffee/ImageOptimiser.coffee b/services/filestore/app/coffee/ImageOptimiser.coffee index 33c8cc8d56..939023a997 100644 --- a/services/filestore/app/coffee/ImageOptimiser.coffee +++ b/services/filestore/app/coffee/ImageOptimiser.coffee @@ -11,10 +11,12 @@ module.exports = timeout: 30 * 1000 killSignal: "SIGKILL" exec args, opts,(err, stdout, stderr)-> + if err? and err?.signal == 'SIGKILL' + logger.warn {err: err, stderr: stderr, localPath: localPath}, "optimiser timeout reached" + err = null if err? logger.err err:err, stderr:stderr, localPath:localPath, "something went wrong converting compressPng" else logger.log localPath:localPath, "finished compressPng file" callback(err) - diff --git a/services/filestore/test/unit/coffee/ImageOptimiserTests.coffee b/services/filestore/test/unit/coffee/ImageOptimiserTests.coffee index 80ca0c1d66..e16d8e0917 100644 --- a/services/filestore/test/unit/coffee/ImageOptimiserTests.coffee +++ b/services/filestore/test/unit/coffee/ImageOptimiserTests.coffee @@ -17,6 +17,7 @@ describe "ImageOptimiser", -> "logger-sharelatex": log:-> err:-> + warn:-> @sourcePath = "/this/path/here.eps" @error = "Error" @@ -36,4 +37,14 @@ describe "ImageOptimiser", -> @child_process.exec.callsArgWith(2, @error) @optimiser.compressPng @sourcePath, (err)=> err.should.equal @error - done() \ No newline at end of file + done() + + describe 'when optimiser is sigkilled', -> + + it 'should not produce an error', (done) -> + @error = new Error('woops') + @error.signal = 'SIGKILL' + @child_process.exec.callsArgWith(2, @error) + @optimiser.compressPng @sourcePath, (err)=> + expect(err).to.equal(null) + done()