fix: preserve early workflow events in streams transport - #40981
Open
Zhengcy05 wants to merge 1 commit into
Open
fix: preserve early workflow events in streams transport#40981Zhengcy05 wants to merge 1 commit into
Zhengcy05 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Fixes #<issue number>.Summary
Fixes #40948.
Redis Streams subscriptions currently start from
$, while streaming workflow tasks are enqueued before the listener performs its firstXREAD. A fast worker can therefore publishworkflow_startedand early node events before$is resolved, causing those events to be skipped even though they remain stored in Redis.This PR captures the stream tip before dispatching a fresh workflow task and uses it as that subscription's starting cursor. Subscriptions without an explicit cursor continue to default to
$, preserving the live-only behavior introduced to avoid replaying staleworkflow_pausedevents in #34040.Changes include:
0-0, since workflow streams are created lazily by the firstXADD.$only observes entries appended after the initial read.$behavior.Validation:
uv run --project api pytest -q api/tests/unit_tests/libs/broadcast_channel/redis/test_streams_channel_unit_tests.py api/tests/unit_tests/services/test_app_generate_service_streaming_integration.py api/tests/unit_tests/services/test_app_generate_service.py— 71 passed.Screenshots
N/A — backend event-delivery fix.
Checklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint gods