馃挜 Preserve non-cancellable timed promise waits during cancellation - #3029
Open
Quinn-With-Two-Ns wants to merge 1 commit into
Open
馃挜 Preserve non-cancellable timed promise waits during cancellation#3029Quinn-With-Two-Ns wants to merge 1 commit into
Quinn-With-Two-Ns wants to merge 1 commit into
Conversation
Quinn-With-Two-Ns
marked this pull request as ready for review
August 27, 2026 21:00
Quinn-With-Two-Ns
force-pushed
the
issue-3026
branch
from
August 27, 2026 21:00
e9a6774 to
05d1a03
Compare
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.
What was changed
This change adds the
DETACH_NON_CANCELLABLE_PROMISE_GET_TIMERSDK flag and updates timed, non-cancellablePromise.get(timeout, unit)calls to run their timeout timer in a detached cancellation scope. The timer is canceled after the promise completes. Regression and replay tests cover promise completion, timeouts, activity cancellation, child workflow cancellation, and combinations withCANCEL_AWAIT_TIMER_ON_CONDITION. The activity tests use per-test latches for deterministic synchronization.Why?
Promise.get(timeout, unit)is non-cancellable, but cancellation of its enclosing scope previously canceled its timeout timer. This ended the wait early and incorrectly surfaced aTimeoutException, potentially hiding the actual activity or child workflow cancellation. The new SDK flag preserves replay compatibility for existing workflow histories while allowing new workflows to use the corrected behaviour.馃挜 Breaking changes
This change can affect workflow behaviour because timed, non-cancellable
Promise.get(timeout, unit)calls will no longer return early with aTimeoutExceptionwhen their enclosing cancellation scope is canceled. Instead, they will continue waiting until the promise completes, fails, or reaches its actual timeout. Workflows that currently catch the prematureTimeoutExceptionand use it to select a control flow path may therefore produce different results. The behaviour is protected by an SDK flag so existing workflow histories retain their original behaviour during replay, while new workflows can adopt the corrected semantics without causing nondeterminism.Checklist
Closes Promise.get(timeout, unit) throws a misleading TimeoutException when the workflow is canceled聽#3026
How was this tested:
Note
High Risk
Changes core workflow promise/cancellation semantics behind an SDK flag; enabling it alters control flow for workflows that relied on premature timeouts when scopes were canceled.
Overview
Fixes incorrect
TimeoutExceptionwhen aCancellationScopeis canceled while a non-cancellablePromise.get(timeout, unit)is waiting: the enclosing cancellation used to cancel the internal await timer and end the wait early.Introduces
SdkFlag.DETACH_NON_CANCELLABLE_PROMISE_GET_TIMER(pending enablement) and, when that flag is present in execution metadata, runs the timed await inside a detached cancellation scope and cancels that scope in afinallyafter the wait finishes.WorkflowInternal.checkSdkFlagexposes flag lookup forCompletablePromiseImpl.cancellableGetis unchanged.Adds parameterized integration tests (promise completion, real timeout, activity/child cancellation) plus 12 replay history fixtures covering combinations with
CANCEL_AWAIT_TIMER_ON_CONDITION.Reviewed by Cursor Bugbot for commit 05d1a03. Bugbot is set up for automated code reviews on this repo. Configure here.