Skip to content

Commit fb37e96

Browse files
committed
add thinClient a condition for additional heartbeat
1 parent d07aa7a commit fb37e96

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionProvider.kt

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,25 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
210210
connectionLifetime.launch {
211211
while (isActive) {
212212
val delaySeconds = 30 + nextInt(5, 15)
213-
try {
214-
val ideUrlStr = lastUpdate?.ideUrl
215-
val ideUrl = if (ideUrlStr.isNullOrBlank()) {
216-
null
217-
} else {
218-
URL(ideUrlStr.replace(connectParams.actualWorkspaceId, connectParams.resolvedWorkspaceId))
219-
}
220-
if (lastUpdate?.status?.phase == "running" && ideUrl != null) {
221-
sendHeartBeatThroughSupervisor(ideUrl, ownerToken, connectParams)
213+
if (thinClientJob?.isActive == true) {
214+
try {
215+
val ideUrlStr = lastUpdate?.ideUrl
216+
val ideUrl = if (ideUrlStr.isNullOrBlank()) {
217+
null
218+
} else {
219+
URL(ideUrlStr.replace(connectParams.actualWorkspaceId, connectParams.resolvedWorkspaceId))
220+
}
221+
if (lastUpdate?.status?.phase == "running" && ideUrl != null) {
222+
sendHeartBeatThroughSupervisor(ideUrl, ownerToken, connectParams)
223+
}
224+
} catch (t: Throwable) {
225+
thisLogger().error(
226+
"gitpod: failed to send additional heartbeat for ${connectParams.resolvedWorkspaceId}",
227+
t
228+
)
222229
}
223-
} catch (t: Throwable) {
224-
thisLogger().error(
225-
"gitpod: failed to send additional heartbeat for ${connectParams.resolvedWorkspaceId}",
226-
t
227-
)
230+
} else {
231+
thisLogger().debug("gitpod: thinClient is not active, skipping additional heartbeat for ${connectParams.resolvedWorkspaceId}")
228232
}
229233
delay(delaySeconds * 1000L)
230234
}
@@ -585,7 +589,7 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
585589
thisLogger().error("gitpod: sendHeartbeat ${connectParams.actualWorkspaceId} failed: ${resp.statusCode}, body: ${resp.body}")
586590
return
587591
}
588-
thisLogger().info("gitpod: =========sendHeartbeat succeed")
592+
thisLogger().debug("gitpod: sendHeartbeat succeed for ${connectParams.actualWorkspaceId}")
589593
}
590594

591595
private fun resolveCredentials(

0 commit comments

Comments
 (0)