Просмотр исходного кода

Merge pull request #8535 from overleaf/jpa-missing-return

[web] add a missing return statement from an error branch

GitOrigin-RevId: 282972cee23f6b426413ede0885695e386fc9352
Jakob Ackermann 4 лет назад
Родитель
Сommit
4660029e38

+ 1 - 0
services/web/app/src/Features/Compile/CompileController.js

@@ -289,6 +289,7 @@ module.exports = CompileController = {
           'something went wrong compile and downloading pdf'
           'something went wrong compile and downloading pdf'
         )
         )
         res.sendStatus(500)
         res.sendStatus(500)
+        return
       }
       }
       const url = `/project/${projectId}/output/output.pdf`
       const url = `/project/${projectId}/output/output.pdf`
       CompileController.proxyToClsi(projectId, url, req, res, next)
       CompileController.proxyToClsi(projectId, url, req, res, next)

+ 8 - 1
services/web/test/unit/src/Compile/CompileControllerTests.js

@@ -836,7 +836,7 @@ describe('CompileController', function () {
       }
       }
       this.CompileManager.compile.callsArgWith(3)
       this.CompileManager.compile.callsArgWith(3)
       this.CompileController.proxyToClsi = sinon.stub()
       this.CompileController.proxyToClsi = sinon.stub()
-      this.res = { send: () => {} }
+      this.res = { send: () => {}, sendStatus: sinon.stub() }
     })
     })
 
 
     it('should call compile in the compile manager', function (done) {
     it('should call compile in the compile manager', function (done) {
@@ -865,6 +865,13 @@ describe('CompileController', function () {
         .should.equal(true)
         .should.equal(true)
       done()
       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 () {
   describe('wordCount', function () {