Skip to content

Conversation

@TomasMikula
Copy link

Resolves #3642: non-terminating subscription stream on race condition between Topic's subscribe and close.

Builds on PR #3643 (failing test).


Resource.eval(signalClosure.tryGet).flatMap {
case Some(_) => Resource.pure(Stream.empty)
case None =>
Copy link
Author

@TomasMikula TomasMikula Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the original race condition: signalClosure.tryGet returns None, but by the time we subscribe the Topic might have been closed and subscription Stream never terminates.

Fixed by making the state Ref able to determine closure. I.e., check and update a single Ref, instead of checking a Deferred and updating a Ref.

@TomasMikula TomasMikula marked this pull request as ready for review January 14, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subscribing to Topic concurrently to closing the Topic leads to non-terminating subscription stream

1 participant