From 67dbf743e1319e9ef3ccc391c457c9c2e80c787c Mon Sep 17 00:00:00 2001 From: Eric Mc Sween <5454374+emcsween@users.noreply.github.com> Date: Thu, 27 Jun 2024 16:24:05 -0400 Subject: [PATCH] Merge pull request #19192 from overleaf/em-project-history-avoid-crash Prevent project-history crashes when generating a diff GitOrigin-RevId: 513fb846f0884a68d4550783497ae436e1cba00f --- services/project-history/app/js/DiffManager.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/services/project-history/app/js/DiffManager.js b/services/project-history/app/js/DiffManager.js index 75cf9afa56..69c9b2f4ed 100644 --- a/services/project-history/app/js/DiffManager.js +++ b/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) }