Skip to content

Commit 614aeaf

Browse files
committed
fix(startup): guard the SNTP clock drift probe against startup failures
1 parent 7d254be commit 614aeaf

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

‎apps/flipcash/app/src/main/kotlin/com/flipcash/app/internal/startup/ClockDriftInitializer.kt‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import com.flipcash.app.internal.time.SntpClient
66
import com.getcode.utils.ClockSource
77
import com.getcode.utils.TraceManager
88
import com.getcode.utils.trace
9-
import kotlinx.coroutines.CoroutineScope
10-
import kotlinx.coroutines.Dispatchers
11-
import kotlinx.coroutines.launch
129

1310
/**
1411
* Best-effort SNTP measurement of how far the device clock has drifted from real time, taken once at
@@ -22,11 +19,11 @@ import kotlinx.coroutines.launch
2219
class ClockDriftInitializer : Initializer<Unit> {
2320

2421
override fun create(context: Context) {
25-
CoroutineScope(Dispatchers.IO).launch {
22+
launchBestEffort(tag = "clock") {
2623
val offsetMillis = SntpClient.queryClockOffsetMillis()
2724
if (offsetMillis == null) {
2825
trace(tag = "clock", message = "Clock drift on launch: unavailable (SNTP query failed)")
29-
return@launch
26+
return@launchBestEffort
3027
}
3128
// drift = device time - true time = negative of the NTP offset (true - device).
3229
val driftMillis = -offsetMillis

0 commit comments

Comments
 (0)