Skip to content

Make watch queries easier to cancel #92

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

Merged
merged 3 commits into from
May 22, 2025
Merged

Conversation

simolus3
Copy link
Contributor

This refactors our watch query stream implementation slightly:

  1. Addressing the FIXME comment in watch(), this refactors the stream implementation there to use stream combinators instead of async*. As that comment explains, cancelling the stream might run the query another time which is not typically what users want.
  2. The _throttleStream implementation, also using async*, had a similar issue where it couldn't be cancelled efficiently when it's in the await Future.delayed(timeout); stage. I've rewritten that method with a manual stream subscription to be more explicit about how we deal with downstream listeners pausing / cancelling the stream (personally, I find the exact semantics of async* quite hard to understand).

@simolus3 simolus3 requested a review from rkistner May 22, 2025 09:03
Copy link
Contributor

@rkistner rkistner left a comment

Choose a reason for hiding this comment

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

Added some minor comments, but looks great overall

@simolus3 simolus3 merged commit 238853b into main May 22, 2025
6 checks passed
@simolus3 simolus3 deleted the allow-cancelling-watch-streams branch May 22, 2025 10:11
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.

2 participants