Skip to content

Commit 7685b37

Browse files
committed
Provide better error when dd times out
1 parent 05a45a3 commit 7685b37

File tree

1 file changed

+10
-1
lines changed
  • src/main/kotlin/com/coder/gateway/sdk

1 file changed

+10
-1
lines changed

src/main/kotlin/com/coder/gateway/sdk/Retry.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.coder.gateway.sdk
33
import com.intellij.openapi.diagnostic.Logger
44
import com.intellij.openapi.progress.ProcessCanceledException
55
import com.intellij.ssh.SshException
6+
import com.jetbrains.gateway.ssh.deploy.DeployException
67
import kotlinx.coroutines.delay
78
import java.util.Random
89
import 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

Comments
 (0)