Browse Source

Merge pull request #509 from sharelatex/ja-fix-clsi-cookie-cluster

Don't try to set the server id if it isn't returned in the response
James Allen 9 years ago
parent
commit
76b8fecde9

+ 2 - 0
services/web/app/coffee/Features/Compile/ClsiCookieManager.coffee

@@ -44,6 +44,8 @@ module.exports = ClsiCookieManager =
 		if !clsiCookiesEnabled
 		if !clsiCookiesEnabled
 			return callback()
 			return callback()
 		serverId = ClsiCookieManager._parseServerIdFromResponse(response)
 		serverId = ClsiCookieManager._parseServerIdFromResponse(response)
+		if !serverId? # We don't get a cookie back if it hasn't changed
+			return callback()
 		if rclient_secondary?
 		if rclient_secondary?
 			@_setServerIdInRedis rclient_secondary, project_id, serverId
 			@_setServerIdInRedis rclient_secondary, project_id, serverId
 		@_setServerIdInRedis rclient, project_id, serverId, (err) ->
 		@_setServerIdInRedis rclient, project_id, serverId, (err) ->

+ 6 - 1
services/web/test/UnitTests/coffee/Compile/ClsiCookieManagerTests.coffee

@@ -105,13 +105,18 @@ describe "ClsiCookieManager", ->
 				serverId.should.equal "clsi-8"
 				serverId.should.equal "clsi-8"
 				done()
 				done()
 
 
-
 		it "should not set the server id if clsiCookies are not enabled", (done)->
 		it "should not set the server id if clsiCookies are not enabled", (done)->
 			delete @settings.clsiCookie.key 
 			delete @settings.clsiCookie.key 
 			@ClsiCookieManager = SandboxedModule.require modulePath, requires:@requires
 			@ClsiCookieManager = SandboxedModule.require modulePath, requires:@requires
 			@ClsiCookieManager.setServerId @project_id, @response, (err, serverId)=>
 			@ClsiCookieManager.setServerId @project_id, @response, (err, serverId)=>
 				@redisMulti.exec.called.should.equal false
 				@redisMulti.exec.called.should.equal false
 				done()
 				done()
+
+		it "should not set the server id there is no server id in the response", (done)->
+			@ClsiCookieManager._parseServerIdFromResponse = sinon.stub().returns(null)
+			@ClsiCookieManager.setServerId @project_id, @response, (err, serverId)=>
+				@redisMulti.exec.called.should.equal false
+				done()
 		
 		
 		it "should also set in the secondary if secondary redis is enabled", (done) ->
 		it "should also set in the secondary if secondary redis is enabled", (done) ->
 			@redisSecondaryMulti =
 			@redisSecondaryMulti =