Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase service start timeout to 1_000ms #537

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading