diff --git a/ethers-providers/src/main/kotlin/io/ethers/providers/SubscriptionStream.kt b/ethers-providers/src/main/kotlin/io/ethers/providers/SubscriptionStream.kt index 55e6768..71bbc0c 100644 --- a/ethers-providers/src/main/kotlin/io/ethers/providers/SubscriptionStream.kt +++ b/ethers-providers/src/main/kotlin/io/ethers/providers/SubscriptionStream.kt @@ -106,7 +106,15 @@ class BlockingSubscriptionStream private constructor( // if no next element, wait until next event to avoid CPU cycle burning if (next == null) { - lock.withLock { newEventCondition.await() } + lock.withLock { + // re-check the queue, as it might have been modified by the time we got the lock, and the + // signalling of the condition might have been missed + next = eventQueue.poll() + + if (next == null) { + newEventCondition.await() + } + } } }