Skip to content

Commit 3679ec4

Browse files
committed
impl: don't re-initialize the http session when waking up from sleep
1 parent f255edb commit 3679ec4

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ class CoderRemoteProvider(
160160
} catch (ex: Exception) {
161161
val elapsed = lastPollTime.elapsedNow()
162162
if (elapsed > POLL_INTERVAL * 2) {
163-
context.logger.info("wake-up from an OS sleep was detected, going to re-initialize the http client...")
164-
client.setupSession()
163+
context.logger.info("wake-up from an OS sleep was detected")
165164
} else {
166165
context.logger.error(ex, "workspace polling error encountered, trying to auto-login")
167166
if (ex is APIResponseException && ex.isTokenExpired) {
@@ -175,7 +174,6 @@ class CoderRemoteProvider(
175174
}
176175
}
177176

178-
// TODO: Listening on a web socket might be better?
179177
select {
180178
onTimeout(POLL_INTERVAL) {
181179
context.logger.trace("workspace poller waked up by the $POLL_INTERVAL timeout")

src/main/kotlin/com/coder/toolbox/sdk/CoderRestClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ open class CoderRestClient(
6060
setupSession()
6161
}
6262

63-
fun setupSession() {
63+
private fun setupSession() {
6464
moshi =
6565
Moshi.Builder()
6666
.add(ArchConverter())

0 commit comments

Comments
 (0)