[web] try harder at flushing projects during soft deletion (#32454)

GitOrigin-RevId: 2e35e75d4219b720e7d12ff7a5534bf1ed302d98
This commit is contained in:
Jakob Ackermann
2026-03-27 09:11:39 +01:00
committed by Copybot
parent be67efb4d7
commit 8fa18e6296

View File

@@ -184,9 +184,30 @@ async function deleteProject(projectId, options = {}) {
throw new Errors.NotFoundError('project not found')
}
await DocumentUpdaterHandler.promises.flushProjectToMongoAndDelete(
projectId
)
try {
// flushProjectToMongoAndDelete performs flush to mongo and history.
await DocumentUpdaterHandler.promises.flushProjectToMongoAndDelete(
projectId
)
} catch (err) {
// Try harder at flushing the project.
// Step 1: Flush to mongo, do not delete yet
await DocumentUpdaterHandler.promises.flushProjectToMongo(projectId)
try {
// Step 2: Attempt to flush the history, this will likely fail.
await HistoryManager.promises.flushProject(projectId)
} catch {
// We found a project with a broken history.
// Step 3: Resync the history
await HistoryManager.promises.resyncProject(projectId, {
force: true,
})
}
// Step 4: Try again, this time delete the docs
await DocumentUpdaterHandler.promises.flushProjectToMongoAndDelete(
projectId
)
}
try {
// OPTIMIZATION: flush docs out of mongo