diff --git a/services/web/app/src/Features/Compile/CompileController.js b/services/web/app/src/Features/Compile/CompileController.js index 2308c087c4..51ef899cff 100644 --- a/services/web/app/src/Features/Compile/CompileController.js +++ b/services/web/app/src/Features/Compile/CompileController.js @@ -289,6 +289,7 @@ module.exports = CompileController = { 'something went wrong compile and downloading pdf' ) res.sendStatus(500) + return } const url = `/project/${projectId}/output/output.pdf` CompileController.proxyToClsi(projectId, url, req, res, next) diff --git a/services/web/test/unit/src/Compile/CompileControllerTests.js b/services/web/test/unit/src/Compile/CompileControllerTests.js index e9897c6de8..1fa97a0105 100644 --- a/services/web/test/unit/src/Compile/CompileControllerTests.js +++ b/services/web/test/unit/src/Compile/CompileControllerTests.js @@ -836,7 +836,7 @@ describe('CompileController', function () { } this.CompileManager.compile.callsArgWith(3) this.CompileController.proxyToClsi = sinon.stub() - this.res = { send: () => {} } + this.res = { send: () => {}, sendStatus: sinon.stub() } }) it('should call compile in the compile manager', function (done) { @@ -865,6 +865,13 @@ describe('CompileController', function () { .should.equal(true) done() }) + + it('should not download anything on compilation failures', function () { + this.CompileManager.compile.yields(new Error('failed')) + this.CompileController.compileAndDownloadPdf(this.req, this.res) + this.res.sendStatus.should.have.been.calledWith(500) + this.CompileController.proxyToClsi.should.not.have.been.called + }) }) describe('wordCount', function () {