@@ -3,6 +3,7 @@ package com.coder.gateway.sdk
3
3
import com.intellij.openapi.diagnostic.Logger
4
4
import com.intellij.openapi.progress.ProcessCanceledException
5
5
import com.intellij.ssh.SshException
6
+ import com.jetbrains.gateway.ssh.deploy.DeployException
6
7
import kotlinx.coroutines.delay
7
8
import java.util.Random
8
9
import java.util.concurrent.TimeUnit
@@ -67,7 +68,15 @@ suspend fun <T> suspendingRetryWithExponentialBackOff(
67
68
while (remainingMs > 0 ) {
68
69
val remainingS = TimeUnit .MILLISECONDS .toSeconds(remainingMs)
69
70
val remaining = if (remainingS < 1 ) " now" else " in $remainingS second${if (remainingS > 1 ) " s" else " " } "
70
- update(attempt, unwrappedEx, remaining)
71
+ // When the worker upload times out Gateway just says it failed.
72
+ // Even the root cause (IllegalStateException) is useless. The
73
+ // error also includes a very long useless tmp path. With all
74
+ // that in mind, provide a better error.
75
+ val mungedEx =
76
+ if (unwrappedEx is DeployException && unwrappedEx.message.contains(" Worker binary deploy failed" ))
77
+ DeployException (" Failed to upload worker binary...it may have timed out" , unwrappedEx)
78
+ else unwrappedEx
79
+ update(attempt, mungedEx, remaining)
71
80
val next = min(remainingMs, TimeUnit .SECONDS .toMillis(1 ))
72
81
remainingMs - = next
73
82
delay(next)
0 commit comments