From 0586f4d68235fd0fcc2d24a943f4376b37aa7cec Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Wed, 8 Apr 2020 14:44:01 +0100 Subject: [PATCH] Merge pull request #2714 from overleaf/cmg-jpa-call-stack-exceeded Stop call stack from being exceeding when adding many files GitOrigin-RevId: 1983b0c16cb279c6f173f614d541d16852664e24 --- .../web/app/src/Features/Project/ProjectRootDocManager.js | 8 ++++++-- .../test/unit/src/Project/ProjectRootDocManagerTests.js | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/services/web/app/src/Features/Project/ProjectRootDocManager.js b/services/web/app/src/Features/Project/ProjectRootDocManager.js index 89f79f2e5a..43459b0489 100644 --- a/services/web/app/src/Features/Project/ProjectRootDocManager.js +++ b/services/web/app/src/Features/Project/ProjectRootDocManager.js @@ -43,9 +43,13 @@ module.exports = ProjectRootDocManager = { ProjectEntityUpdateHandler.isPathValidForRootDoc(path) && DocumentHelper.contentHasDocumentclass(doc.lines) ) { - return cb(doc._id) + async.setImmediate(function() { + cb(doc._id) + }) } else { - return cb(null) + async.setImmediate(function() { + cb(null) + }) } } ) diff --git a/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js b/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js index 9f6f28b310..84c1290226 100644 --- a/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js +++ b/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js @@ -113,7 +113,7 @@ describe('ProjectRootDocManager', function() { }) describe('when the root doc is an Rtex file', function() { - beforeEach(function() { + beforeEach(function(done) { this.docs = { '/chapter1.tex': { _id: 'doc-id-1', @@ -129,7 +129,7 @@ describe('ProjectRootDocManager', function() { .callsArgWith(1, null, this.docs) return this.ProjectRootDocManager.setRootDocAutomatically( this.project_id, - this.callback + done ) })