diff --git a/services/web/app/src/Features/Compile/CompileManager.js b/services/web/app/src/Features/Compile/CompileManager.js index 974f573815..7897c3588d 100644 --- a/services/web/app/src/Features/Compile/CompileManager.js +++ b/services/web/app/src/Features/Compile/CompileManager.js @@ -10,6 +10,7 @@ const ClsiManager = require('./ClsiManager') const Metrics = require('@overleaf/metrics') const { RateLimiter } = require('../../infrastructure/RateLimiter') const UserAnalyticsIdCache = require('../Analytics/UserAnalyticsIdCache') +const SplitTestHandler = require('../SplitTests/SplitTestHandler') const { callbackify, callbackifyMultiResult, @@ -123,6 +124,18 @@ async function getProjectCompileLimits(projectId) { if (owner && owner.alphaProgram) { ownerFeatures.compileGroup = 'alpha' } + + if (ownerFeatures.compileTimeout === 20) { + const overrideCompileTimeout = + await SplitTestHandler.promises.getAssignmentForUser( + project.owner_ref, + '10s-timeout-enforcement' + ) + + if (overrideCompileTimeout.variant === 'enabled') { + ownerFeatures.compileTimeout = 10 + } + } const analyticsId = await UserAnalyticsIdCache.get(owner._id) const compileGroup = diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index 2c8d839a33..74ba21e04d 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -736,6 +736,17 @@ const _ProjectController = { isOverleafAssistBundleEnabled && (await ProjectController._getAddonPrices(req, res)) + const reducedTimeout = + await SplitTestHandler.promises.getAssignmentForUser( + project.owner_ref, + '10s-timeout-enforcement' + ) + + let compileTimeout = ownerFeatures?.compileTimeout + if (compileTimeout === 20 && reducedTimeout.variant === 'enabled') { + compileTimeout = 10 + } + let planCode = subscription?.planCode if (!planCode && !userInNonIndividualSub) { planCode = 'personal' @@ -843,7 +854,7 @@ const _ProjectController = { customerIoEnabled, addonPrices, compileSettings: { - compileTimeout: ownerFeatures?.compileTimeout, + compileTimeout, }, }) timer.done() diff --git a/services/web/test/unit/src/Compile/CompileManagerTests.js b/services/web/test/unit/src/Compile/CompileManagerTests.js index 908e2fe803..d6bd844e76 100644 --- a/services/web/test/unit/src/Compile/CompileManagerTests.js +++ b/services/web/test/unit/src/Compile/CompileManagerTests.js @@ -45,6 +45,9 @@ describe('CompileManager', function () { '../Analytics/UserAnalyticsIdCache': (this.UserAnalyticsIdCache = { get: sinon.stub().resolves('abc'), }), + '../SplitTests/SplitTestHandler': (this.SplitTestHandler = { + promises: {}, + }), }, }) this.project_id = 'mock-project-id-123'