From 4660029e382e2379c8e5984ea050d112dcc2064d Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 23 Jun 2022 16:05:58 +0100 Subject: [PATCH] Merge pull request #8535 from overleaf/jpa-missing-return [web] add a missing return statement from an error branch GitOrigin-RevId: 282972cee23f6b426413ede0885695e386fc9352 --- .../web/app/src/Features/Compile/CompileController.js | 1 + .../web/test/unit/src/Compile/CompileControllerTests.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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 () {