generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 4
feat(sdk): migrate waitForCondition to DurablePromise #297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ParidelPooya
merged 7 commits into
development
from
feat/sdk-wait-for-condition-durable-promise
Nov 21, 2025
Merged
feat(sdk): migrate waitForCondition to DurablePromise #297
ParidelPooya
merged 7 commits into
development
from
feat/sdk-wait-for-condition-durable-promise
Nov 21, 2025
Conversation
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
…xecution Migrated wait-for-condition-handler to use DurablePromise pattern, enabling two-phase execution where operations start immediately but only gracefully terminate when awaited. Changes: - Updated handler to return DurablePromise<T> instead of Promise<T> - Implemented phase 1 (immediate execution) and phase 2 (await result) - Added isAwaited flag and waitingCallback mechanism for graceful termination - Updated waitForContinuation and executeWaitForCondition to support onAwaitedChange - Fixed tests to handle synchronous validation errors and DurablePromise instances - Added comprehensive two-phase execution tests This brings waitForCondition in line with other migrated handlers (step, invoke, wait, callback) and ensures consistent behavior across the SDK.
Updated two-phase execution tests for waitForCondition, step, and runInChildContext handlers to assert function execution immediately after a brief timeout (10ms) and before awaiting the DurablePromise. This more clearly demonstrates that phase 1 executes immediately when the handler is called, not when the promise is awaited. Changes: - Reduced timeout from 50ms to 10ms for faster test execution - Added assertions after timeout but before await to prove immediate execution - Applied pattern consistently across all three handlers - All 704 tests still pass
Moved parameter validation inside the async phase 1 promise to match the pattern used by wait-for-callback-handler. This makes validation errors async rejections instead of synchronous throws, providing consistency across handlers. Changes: - Moved validation logic inside phase 1 promise (async) - Updated test to use await expect(...).rejects.toThrow() for async rejection - Matches wait-for-callback pattern for consistency - All 704 tests pass
b782011 to
9c75638
Compare
Configure Jest to automatically retry failed integration tests up to 2 times before marking them as failures. This helps with beta backend issues until we use production for integration tests. Changes: - Added jest.setup.integration.js with jest.retryTimes(2) - Updated jest.config.integration.js to use setupFilesAfterEnv - Logs errors before each retry for debugging
9c75638 to
b15dd26
Compare
This reverts commit b15dd26.
Fixed unused variable warnings: - Removed unused DurableContext import in run-in-child-context-handler-two-phase.test.ts - Prefixed unused state parameters with underscore in wait-for-condition-handler-two-phase.test.ts
bchampp
approved these changes
Nov 21, 2025
anthonyting
reviewed
Nov 21, 2025
...rable-execution-sdk-js/src/handlers/wait-for-condition-handler/wait-for-condition-handler.ts
Show resolved
Hide resolved
anthonyting
reviewed
Nov 21, 2025
...rable-execution-sdk-js/src/handlers/wait-for-condition-handler/wait-for-condition-handler.ts
Show resolved
Hide resolved
…ions Updated all operations that return DurablePromise to use withDurableModeManagement instead of withModeManagement. This ensures proper mode management for two-phase execution across all durable operations. Changes: - invoke: Promise<O> → DurablePromise<O>, use withDurableModeManagement - wait: Promise<void> → DurablePromise<void>, use withDurableModeManagement - waitForCallback: Promise<T> → DurablePromise<T>, use withDurableModeManagement - waitForCondition: Promise<T> → DurablePromise<T>, use withDurableModeManagement - runInChildContext: Promise<T> → DurablePromise<T>, use withDurableModeManagement All 704 tests pass.
anthonyting
approved these changes
Nov 21, 2025
a52adbe to
512cc67
Compare
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.
Migrated wait-for-condition-handler to use DurablePromise pattern, enabling two-phase execution where operations start immediately but only gracefully terminate when awaited.
Changes:
This brings waitForCondition in line with other migrated handlers (step, invoke, wait, callback) and ensures consistent behavior across the SDK.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.