@@ -3,6 +3,7 @@ package com.coder.gateway.sdk
33import com.intellij.openapi.diagnostic.Logger
44import com.intellij.openapi.progress.ProcessCanceledException
55import com.intellij.ssh.SshException
6+ import com.jetbrains.gateway.ssh.deploy.DeployException
67import kotlinx.coroutines.delay
78import java.util.Random
89import java.util.concurrent.TimeUnit
@@ -67,7 +68,15 @@ suspend fun <T> suspendingRetryWithExponentialBackOff(
6768 while (remainingMs > 0 ) {
6869 val remainingS = TimeUnit .MILLISECONDS .toSeconds(remainingMs)
6970 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)
7180 val next = min(remainingMs, TimeUnit .SECONDS .toMillis(1 ))
7281 remainingMs - = next
7382 delay(next)
0 commit comments