Skip to content

fix: prevent redis stream subscriber timeout when polling_interval exceeds 3000ms #2200

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

Conversation

caozheliang
Copy link
Contributor

@caozheliang caozheliang commented May 2, 2025

Description

This PR fixes an issue where StreamSub would timeout when the polling_interval is greater than 3000ms and the consumer group is empty.

Fixes #2199

Type of change

Please delete options that are not relevant.

  • Bug fix (a non-breaking change that resolves an issue)

Checklist

  • My code adheres to the style guidelines of this project (scripts/lint.sh shows no errors)
  • I have conducted a self-review of my own code
  • My changes do not generate any new warnings
  • I have added tests to validate the effectiveness of my fix or the functionality of my new feature
  • Both new and existing unit tests pass successfully on my local environment by running scripts/test-cov.sh
  • I have ensured that static analysis tests are passing by running scripts/static-analysis.sh

When the polling_interval parameter in StreamSub is set to a value greater than 3000 milliseconds,
the client will consistently experience timeouts if the group is empty.

This issue arises because the LogicSubscriber._get_msgs method was simultaneously awaiting messages
and checking the connection status in a single coroutine. This concurrent waiting blocked both paths
under certain conditions, especially when no messages were present.

To resolve this, the logic has been refactored to separate connection state
monitoring and message polling into independent processes. This improves responsiveness and prevents unintended timeouts
in empty group scenarios with high polling intervals.
@caozheliang caozheliang changed the title fix(streamsub): prevent timeout when polling_interval exceeds 3000ms fix: prevent redis stream subscriber timeout when polling_interval exceeds 3000ms May 2, 2025
@Lancetnik Lancetnik added the Redis Issues related to `faststream.redis` module and Redis features label May 3, 2025
@Lancetnik Lancetnik added this pull request to the merge queue May 3, 2025
Merged via the queue into ag2ai:main with commit 49576f6 May 3, 2025
33 checks passed
@caozheliang caozheliang deleted the bugfix/streamsub-polling-interval-timeout branch May 3, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Redis Issues related to `faststream.redis` module and Redis features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: StreamSub with large polling_interval causes timeout when group is empty
2 participants