Sfoglia il codice sorgente

Merge pull request #19192 from overleaf/em-project-history-avoid-crash

Prevent project-history crashes when generating a diff

GitOrigin-RevId: 513fb846f0884a68d4550783497ae436e1cba00f
Eric Mc Sween 2 anni fa
parent
commit
67dbf743e1
1 ha cambiato i file con 12 aggiunte e 1 eliminazioni
  1. 12 1
      services/project-history/app/js/DiffManager.js

+ 12 - 1
services/project-history/app/js/DiffManager.js

@@ -37,7 +37,18 @@ export function getDiff(projectId, pathname, fromVersion, toVersion, callback) {
         if (binary) {
           diff = { binary: true }
         } else {
-          diff = DiffGenerator.buildDiff(initialContent, updates)
+          try {
+            diff = DiffGenerator.buildDiff(initialContent, updates)
+          } catch (err) {
+            return callback(
+              OError.tag(err, 'failed to build diff', {
+                projectId,
+                pathname,
+                fromVersion,
+                toVersion,
+              })
+            )
+          }
         }
         callback(null, diff)
       }