Skip to content

Preserve late events after continue-as-new#711

Merged
berndverst merged 2 commits intomainfrom
split/taskorchestrationcontextwrapper-late-events
Apr 23, 2026
Merged

Preserve late events after continue-as-new#711
berndverst merged 2 commits intomainfrom
split/taskorchestrationcontextwrapper-late-events

Conversation

@berndverst
Copy link
Copy Markdown
Member

Summary

  • extract the TaskOrchestrationContextWrapper late-external-event forwarding change from Harden gRPC worker and client against silent disconnects #708 into its own PR
  • preserve late-arriving external events when ContinueAsNew has already been scheduled with preserveUnprocessedEvents enabled
  • add focused wrapper tests for the ContinueAsNew forwarding behavior

Why

After ContinueAsNew is scheduled with event preservation enabled, late external events should be forwarded to the next execution instead of being buffered on the current wrapper instance that is about to be discarded.

Validation

  • dotnet test .\test\Worker\Core.Tests\Worker.Tests.csproj --filter "TaskOrchestrationContextWrapperTests"

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 23, 2026 21:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the worker shim’s TaskOrchestrationContextWrapper to ensure late-arriving external events are forwarded to the next execution after ContinueAsNew has been scheduled with PreserveUnprocessedEvents enabled, and adds a focused regression test for that behavior.

Changes:

  • Track whether ContinueAsNew(...PreserveUnprocessedEvents=true) has been scheduled, and forward late external events via SendEvent instead of buffering them on the soon-to-be-discarded wrapper.
  • Refactor buffered-event forwarding into a helper method reused by both “drain buffer” and “late event” paths.
  • Add a wrapper test that simulates a late external event after ContinueAsNew and validates an event is sent.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/Worker/Core/Shims/TaskOrchestrationContextWrapper.cs Adds state + forwarding logic so late external events are sent to the next execution after ContinueAsNew with preservation enabled.
test/Worker/Core.Tests/Shims/TaskOrchestrationContextWrapperTests.cs Adds a test exercising the late-event forwarding behavior using a tracking inner context and reflection to invoke CompleteExternalEvent.

Comment thread src/Worker/Core/Shims/TaskOrchestrationContextWrapper.cs Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@berndverst berndverst merged commit a922069 into main Apr 23, 2026
8 checks passed
@berndverst berndverst deleted the split/taskorchestrationcontextwrapper-late-events branch April 23, 2026 21:56
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.

3 participants