Skip to content

Conversation

@ParidelPooya
Copy link
Contributor

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 instead of Promise
  • 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 two-phase execution tests
  • Added assertions after timeout but before await to prove immediate execution
  • Applied pattern consistently across all three handlers

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.

…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
@ParidelPooya ParidelPooya force-pushed the feat/sdk-wait-for-condition-durable-promise branch from b782011 to 9c75638 Compare November 20, 2025 23:12
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
@ParidelPooya ParidelPooya force-pushed the feat/sdk-wait-for-condition-durable-promise branch from 9c75638 to b15dd26 Compare November 20, 2025 23:13
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
…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.
@ParidelPooya ParidelPooya force-pushed the feat/sdk-wait-for-condition-durable-promise branch 2 times, most recently from a52adbe to 512cc67 Compare November 21, 2025 05:56
@ParidelPooya ParidelPooya marked this pull request as ready for review November 21, 2025 06:05
@ParidelPooya ParidelPooya merged commit 0bbf07a into development Nov 21, 2025
21 checks passed
@ParidelPooya ParidelPooya deleted the feat/sdk-wait-for-condition-durable-promise branch November 21, 2025 06:05
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