Sfoglia il codice sorgente

Merge pull request #2714 from overleaf/cmg-jpa-call-stack-exceeded

Stop call stack from being exceeding when adding many files

GitOrigin-RevId: 1983b0c16cb279c6f173f614d541d16852664e24
Simon Detheridge 6 anni fa
parent
commit
0586f4d682

+ 6 - 2
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)
+              })
             }
           }
       )

+ 2 - 2
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
         )
       })