@@ -15,10 +15,13 @@ import org.digma.intellij.plugin.log.Log
1515import org.digma.intellij.plugin.model.rest.AboutResult
1616import org.digma.intellij.plugin.persistence.PersistenceService
1717import org.digma.intellij.plugin.posthog.ActivityMonitor
18+ import org.digma.intellij.plugin.scheduling.disposingOneShotDelayedTask
1819import org.digma.intellij.plugin.scheduling.disposingPeriodicTask
1920import org.digma.intellij.plugin.scheduling.oneShotTask
2021import java.util.concurrent.atomic.AtomicReference
22+ import kotlin.jvm.Throws
2123import kotlin.time.Duration.Companion.minutes
24+ import kotlin.time.Duration.Companion.seconds
2225
2326/* *
2427 * keep the backend info and tracks it on connection events.
@@ -127,8 +130,24 @@ class BackendInfoHolder(val project: Project) : DisposableAdaptor {
127130 }
128131
129132
130- // must be called in background coroutine
133+ // must be called in background coroutine.
134+ // if failed update will try again after 5 seconds
131135 private fun update () {
136+ try {
137+ updateImpl()
138+ } catch (e: Throwable ) {
139+ // if update fails run another try after 2 seconds. maybe it was a momentary error from AnalyticsService.
140+ // if that will not succeed there will be another periodic update soon
141+ disposingOneShotDelayedTask(" BackendInfoHolder.update-fallack" , 5 .seconds.inWholeMilliseconds) {
142+ updateImpl()
143+ }
144+ }
145+ }
146+
147+
148+ // Note that updateImpl rethrows exceptions
149+ @Throws(Throwable ::class )
150+ private fun updateImpl (){
132151 try {
133152 if (isProjectValid(project)) {
134153 Log .log(logger::trace, " updating backend info" )
@@ -144,11 +163,7 @@ class BackendInfoHolder(val project: Project) : DisposableAdaptor {
144163 if (! isConnectionException) {
145164 ErrorReporter .getInstance().reportError(project, " BackendInfoHolder.update" , e)
146165 }
147-
148- // if update fails run another try immediately. maybe it was a momentary error from AnalyticsService.
149- // if that will not succeed then the next execution in 1 minute will hopefully succeed
150- updateInBackground()
151-
166+ throw e;
152167 }
153168 }
154169
0 commit comments