Skip to content

Commit

Permalink
Increase service start timeout to 1_000ms (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
05nelsonm authored Aug 27, 2024
1 parent 2ecbdd8 commit 1ddbf3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,10 @@ public sealed interface TorRuntime:
}

/**
* An instance of [TorRuntime] which produces [Lifecycle.DestroyableTorRuntime]
* An instance of [TorRuntime] that produces [Lifecycle.DestroyableTorRuntime]
* under the hood which are intended to be run within a service object.
*
* **NOTE:** This and its subclasses are currently an [ExperimentalKmpTorApi].
* **NOTE:** This and its subclasses are currently marked as [ExperimentalKmpTorApi].
* Things may change (as the annotation states), so use at your own risk! Prefer
* using the stable implementation via the `kmp-tor:runtime-service` dependency.
*
Expand Down Expand Up @@ -669,7 +669,7 @@ public sealed interface TorRuntime:
*
* Implementors of [ServiceFactory.startService] must start the service
* and call [Binder.onBind] from the injected [binder] reference within
* 500ms, otherwise a timeout will occur and all enqueued jobs waiting
* 1_000ms, otherwise a timeout will occur and all enqueued jobs waiting
* to be handed off to [Lifecycle.DestroyableTorRuntime] for completion
* will be terminated.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -956,21 +956,22 @@ internal class RealTorRuntime private constructor(
_failure = t
}

// Wait for 500ms
// Wait for service startup
TimeSource.Monotonic.markNow().let { mark ->
// Node.js uses Dispatchers.Main so the test coroutine
// library will not wait an actual 500ms. Make it so
// there's a 500ms delay no matter what.
// library will not wait an actual timeout. Make it so
// there's a delay no matter what.
val interval = 100.milliseconds
val timeout = 500.milliseconds
val timeout = 1_000.milliseconds

while (isActive) {
if (_failure != null) break
if (_instance != null) break
delay(interval)
if (_failure != null) break
if (_instance != null) break
if (mark.elapsedNow() < timeout) continue
_failure = InterruptedException("${name.name} timed out after 500ms")
_failure = InterruptedException("${name.name} timed out after 1000ms")
}
}

Expand Down

0 comments on commit 1ddbf3c

Please sign in to comment.