Skip to content

Preserve Workflow Streams after workflow closure - #2803

Draft
brianstrauch wants to merge 1 commit into
mainfrom
codex/preserve-workflow-streams-after-closure
Draft

brianstrauch wants to merge 1 commit into
mainfrom
codex/preserve-workflow-streams-after-closure

Conversation

@brianstrauch

@brianstrauch brianstrauch commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

What was changed

Active subscriptions continue polling through Updates. After Describe confirms completion, failure, cancellation, termination, or timeout, subscriptions query the confirmed run for all remaining retained pages and finish after final delivery. The synchronous __temporal_workflow_stream_poll Query shares PollInput/PollResult and read-only batch collection with the Update. It returns immediately and clamps stale offsets to the retained base.

Accepted-run tracking is local to each subscription attempt. Query errors, failed descriptions, and unconfirmed closure remain errors; terminal reads stay pinned across workflow ID reuse. Existing truncation, draining, cancellation, conversion, and continue-as-new behavior is preserved.

Why?

Subscribing after closure, or closing a run during an accepted poll, could previously end the subscription before its unread retained tail was delivered. Query draining makes retained stream contents available after closure without adding history events.

Checklist

  1. How was this tested:
  • Canonical focused unit tests, Workflow Streams package race tests, and go run . check passed.
  • Canonical real-server integration tests passed with both default caching and WORKFLOW_CACHE_SIZE=0.
  • Covered all five terminal statuses, replay/unchanged history, response-size pagination, truncation/filtering/resume, accepted-poll closure, continue-as-new followed by immediate completion, empty/missing/rejected queries, codecs, ID reuse between pages, and concurrent subscribers.
  • Local validation used the implementation checkout; CI will validate the current-main base.
  1. Any docs updates needed?

Updated the stream guide/API comments and release notes. Workers must be upgraded before upgraded clients use closed-stream reads; retained history and an available compatible worker are required.

  1. Breaking changes / Server PR:

Subscription signatures and existing wire types are unchanged. No Server, Core, or protobuf change is required. Upgraded clients surface missing poll Query errors from older workers.

Coordinated SDK PRs

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.

1 participant