From 3096b64435e1dfd32a37e4124966cf9d6f3fc54a Mon Sep 17 00:00:00 2001 From: lukellmann Date: Tue, 30 Jan 2024 21:20:07 +0100 Subject: [PATCH] Make sure IdentifyRateLimiterImpl.consume does a tail-call --- gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt b/gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt index c75444ef8df7..c3e7b008391e 100644 --- a/gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt +++ b/gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt @@ -81,7 +81,7 @@ private class IdentifyRateLimiterImpl( // if the coroutine that called consume() is cancelled, the CancellableContinuation makes sure the waiting is // stopped (the Gateway won't try to identify), so we don't need to hold the mutex and waste time for other // calls - suspendCancellableCoroutine { continuation -> + return suspendCancellableCoroutine { continuation -> val job = launchIdentifyWaiter(shardId, events, continuation) continuation.invokeOnCancellation { job.cancel() } }