Merge pull request #24 from sharelatex/sk-ignore-png-optimiser-timeout

If optipng is sigkilled by timeout, then ignore that error
This commit is contained in:
Shane Kilkelly 2017-08-03 09:22:43 +01:00 committed by GitHub
commit e162c779d3
2 changed files with 16 additions and 4 deletions

View file

@ -11,10 +11,11 @@ module.exports =
timeout: 30 * 1000
killSignal: "SIGKILL"
exec args, opts,(err, stdout, stderr)->
if err?
if err? and err.signal == 'SIGKILL'
logger.warn {err: err, stderr: stderr, localPath: localPath}, "optimiser timeout reached"
err = null
else 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)

View file

@ -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()
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()