Преглед изворни кода

Merge pull request #3517 from overleaf/jpa-clear-clsi-persistance

[ClsiManager] clear the clsi persistence when clearing the cache

GitOrigin-RevId: 64035ec23b5a95ae5248f65777d5d8c8c088e192
Jakob Ackermann пре 5 година
родитељ
комит
00ba2d95c7

+ 26 - 14
services/web/app/src/Features/Compile/ClsiManager.js

@@ -153,21 +153,33 @@ const ClsiManager = {
       // always clear the project state from the docupdater, even if there
       // was a problem with the request to the clsi
       DocumentUpdaterHandler.clearProjectState(projectId, docUpdaterErr => {
-        if (clsiErr != null) {
-          return callback(
-            OError.tag(clsiErr, 'Failed to delete aux files', { projectId })
-          )
-        }
-        if (docUpdaterErr != null) {
-          return callback(
-            OError.tag(
-              docUpdaterErr,
-              'Failed to clear project state in doc updater',
-              { projectId }
+        ClsiCookieManager.clearServerId(projectId, redisError => {
+          if (clsiErr) {
+            return callback(
+              OError.tag(clsiErr, 'Failed to delete aux files', { projectId })
             )
-          )
-        }
-        callback()
+          }
+          if (docUpdaterErr) {
+            return callback(
+              OError.tag(
+                docUpdaterErr,
+                'Failed to clear project state in doc updater',
+                { projectId }
+              )
+            )
+          }
+          if (redisError) {
+            // redis errors need wrapping as the instance may be shared
+            return callback(
+              OError(
+                'Failed to clear clsi persistence',
+                { projectId },
+                redisError
+              )
+            )
+          }
+          callback()
+        })
       })
     })
   },

+ 7 - 0
services/web/test/unit/src/Compile/ClsiManagerTests.js

@@ -8,6 +8,7 @@ describe('ClsiManager', function() {
   beforeEach(function() {
     this.jar = { cookie: 'stuff' }
     this.ClsiCookieManager = {
+      clearServerId: sinon.stub().yields(),
       getCookieJar: sinon.stub().callsArgWith(1, null, this.jar),
       setServerId: sinon.stub().callsArgWith(2),
       _getServerId: sinon.stub()
@@ -420,6 +421,12 @@ describe('ClsiManager', function() {
           .should.equal(true)
       })
 
+      it('should clear the clsi persistance', function() {
+        this.ClsiCookieManager.clearServerId
+          .calledWith(this.project_id)
+          .should.equal(true)
+      })
+
       it('should call the callback', function() {
         this.callback.called.should.equal(true)
       })