From 8a07819689fa6239382fe047cd7162ef7d2eecbd Mon Sep 17 00:00:00 2001 From: Sascha Lisson Date: Wed, 26 Feb 2025 09:56:22 +0100 Subject: [PATCH] fix(mps-sync-plugin): handle exceptions during initial sync --- .../kotlin/org/modelix/mps/sync3/BindingWorker.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mps-sync-plugin3/src/main/kotlin/org/modelix/mps/sync3/BindingWorker.kt b/mps-sync-plugin3/src/main/kotlin/org/modelix/mps/sync3/BindingWorker.kt index a514edc970..0f6eabc057 100644 --- a/mps-sync-plugin3/src/main/kotlin/org/modelix/mps/sync3/BindingWorker.kt +++ b/mps-sync-plugin3/src/main/kotlin/org/modelix/mps/sync3/BindingWorker.kt @@ -2,6 +2,7 @@ package org.modelix.mps.sync3 import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ModalityState +import io.ktor.utils.io.CancellationException import jetbrains.mps.project.MPSProject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -91,7 +92,17 @@ class BindingWorker( private suspend fun CoroutineScope.syncJob() { // initial sync - initialSync() + while (isActive()) { + try { + initialSync() + break + } catch (ex: CancellationException) { + break + } catch (ex: Exception) { + LOG.error(ex) { "Initial synchronization failed" } + delay(5_000) + } + } // continuous sync to MPS launchLoop {