Skip to content

fix(workflow_streams): retry aborted unaccepted polls - #2172

Open
feiiiiii5 wants to merge 1 commit into
temporalio:mainfrom
feiiiiii5:fix/2170-continue-as-new-poll
Open

feiiiiii5 wants to merge 1 commit into
temporalio:mainfrom
feiiiiii5:fix/2170-continue-as-new-poll

Conversation

@feiiiiii5

Copy link
Copy Markdown

What was changed

WorkflowStreamClient.subscribe() now retries a poll aborted before acceptance with FAILED_PRECONDITION and a WorkflowNotReadyFailure detail. That is the error the server produces when a publish lands in the workflow task that emits continue-as-new. The retry is limited to the unaccepted case: accepted-run errors, generic RPC errors, cancellation, and terminal handling are unchanged.

The public docstring now states that unaccepted polls aborted with WorkflowNotReadyFailure are retried. A changelog/fixed/ fragment is included. The fix uses only local per-attempt state; it adds no cache, client, connection, loop, timer, or retained global state.

Why?

Issue #2170 reports that a healthy token-stream subscriber dies because subscribe() describes the run, sees RUNNING, and re-raises the aborted poll error. The method already retries unaccepted polls for StreamDraining and promises to follow continue-as-new chains. A stress reproduction lost 6 of 20 subscribers at rollover under publish load.

Checklist

  1. Closes [Bug] workflow_streams: subscribe() raises RPCError when a publish signal lands during the continue-as-new workflow task #2170

  2. How was this tested:

    • Base ce8cd48149423e005302ae0b4ea5f5488d90a4f3 + new tests: 1 failed, 1 passed. The retry test failed with the reported RPCError.
    • This branch: focused tests 2 passed; broader closed-stream unit subset 24 passed.
    • ruff check --select I and ruff format --check pass on both changed Python files; git diff --check passes.
    • Full uv dev install timed out downloading the unrelated cibuildwheel package, so tests ran with the local Python 3.11 environment and the installed native bridge shim. Integration tests requiring a Temporal dev server were not run.
    • Local Ruff 0.16.6 reports three pre-existing findings in untouched lines; this repo pins Ruff <0.16.
  3. Any docs updates needed?

    • Updated the subscribe() docstring and added a changelog/fixed/ fragment. No docs.temporal.io update is needed.

🤖 Generated with Claude Code

Unaccepted polls aborted with WorkflowNotReadyFailure during continue-as-new are retried instead of ending the subscription.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@feiiiiii5
feiiiiii5 requested review from a team as code owners November 29, 2026 04:20
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-29T04:20:59.816136Z
We couldn’t complete this review. Comment @codex review to try again.
569e9ae PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown

I ran the deterministic loopback reproduction from #2170 against main ce8cd48 and this PR at 569e9ae on macOS arm64 with Python 3.13 and Temporal CLI 1.10.1 (Server 1.32.2). The official Python SDK 1.37.0 wheel and the main client both lost the subscriber with the reported RPCError. This PR and a separate restore of the same commit both delivered hello. All four runs recorded the server's UNHANDLED_COMMAND workflow-task failure, and the workflow remained RUNNING at offset 1, so the successful runs still exercised the reported collision.

Replayed with Codex assistance.

This branch has not been deployed

No deployments
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.

[Bug] workflow_streams: subscribe() raises RPCError when a publish signal lands during the continue-as-new workflow task

3 participants