Skip to content

fix(wait_event): drain signals with a blocking Receive loop (EN-1223) - #186

Closed
flemzord wants to merge 1 commit into
mainfrom
fix/wait-event-receive-loop
Closed

fix(wait_event): drain signals with a blocking Receive loop (EN-1223)#186
flemzord wants to merge 1 commit into
mainfrom
fix/wait-event-receive-loop

Conversation

@flemzord

Copy link
Copy Markdown
Member

Problem (H3 — HIGH)

RunWaitEvent called channel.ReceiveAsync inside a workflow.Await predicate:

return workflow.Await(ctx, func() bool {
    var signal internalWorkflow.Event
    ok := channel.ReceiveAsync(&signal)
    ...
})

An Await predicate is evaluated only once per workflow-task wakeup. If a non-matching signal and the matching signal arrive in the same workflow task, the predicate consumes the non-matching one, returns false, and the matching signal stays buffered with nothing left to re-wake the coroutine — the stage blocks forever. Non-matching events are also silently destroyed.

Fix

Canonical blocking Receive loop that drains signals one at a time until the expected event arrives:

for {
    var signal internalWorkflow.Event
    channel.Receive(ctx, &signal)
    if signal.Name == waitEvent.Event { return nil }
}

Test

Adds a TestWaitEvent case signaling a non-matching event then the matching one in the same task; the stage completes (it would hang under the old implementation).

Severity: HIGH.

RunWaitEvent called channel.ReceiveAsync inside a workflow.Await
predicate. An Await predicate is only evaluated once per workflow-task
wakeup, so if a non-matching signal and the matching signal were
delivered in the same workflow task, the predicate consumed the
non-matching one, returned false, and the matching signal stayed
buffered with nothing left to re-wake the coroutine -- blocking the
stage forever. Non-matching events were also silently destroyed.

Replace it with the canonical blocking Receive loop that drains signals
one at a time until the expected event arrives.

Adds a regression test signaling a non-matching then matching event in
the same task.
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@flemzord, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 22 minutes and 46 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6e502a02-59e0-4f5b-b806-1bf3065ab932

📥 Commits

Reviewing files that changed from the base of the PR and between 271bf8d and bd6b167.

📒 Files selected for processing (2)
  • internal/workflow/stages/wait_event/run.go
  • internal/workflow/stages/wait_event/wait_event_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/wait-event-receive-loop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@flemzord

flemzord commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

Tracked in Jira: EN-1223 (Epic EN-1217).

@flemzord flemzord changed the title fix(wait_event): drain signals with a blocking Receive loop fix(wait_event): drain signals with a blocking Receive loop (EN-1223) Jun 11, 2026
@flemzord

flemzord commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

Superseded by #199, which consolidates this change with the related reliability and safety fixes on top of the current main branch.

@flemzord flemzord closed this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant