refactor: streamline orchestration event handling and improve state management#115
Open
refactor: streamline orchestration event handling and improve state management#115
Conversation
…anagement - Simplified the handling of various orchestration events by extracting logic into dedicated methods for better readability and maintainability. - Updated the StateShim class to use a more concise null check for state presence. - Enhanced error handling for entity operations and task failures, ensuring clearer logging and state recovery. - Removed commented-out code in RuntimeOrchestrationContext's setFailed method to clarify intent and functionality.
There was a problem hiding this comment.
Pull request overview
Refactors core Durable Task JS orchestration execution/event handling and related utilities to reduce complexity while keeping behavior consistent across workers, tracing, and Azure Managed configuration.
Changes:
- Split
OrchestrationExecutor.processEvent’s large switch into focused handler methods and shared helpers for completed/failed tasks. - Introduced
parseJsonFieldand reduced duplication in protobuf helper utilities (including entity message action wrapping). - Simplified/standardized small patterns in tracing, paging, entity state checks, and Azure Managed options/credential construction.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/durabletask-js/src/worker/runtime-orchestration-context.ts | Removes dead/commented code in failure handling path. |
| packages/durabletask-js/src/worker/orchestration-executor.ts | Refactors orchestration history event processing into dedicated handlers and shared task helpers; switches JSON parsing to parseJsonField. |
| packages/durabletask-js/src/worker/entity-executor.ts | Simplifies null/undefined checks for entity state serialization. |
| packages/durabletask-js/src/utils/pb-helper.util.ts | Adds parseJsonField and refactors entity message action construction to use a shared wrapper. |
| packages/durabletask-js/src/utils/history-event-converter.ts | Replaces monolithic switch with per-event converter functions and a dispatch map. |
| packages/durabletask-js/src/tracing/trace-helper.ts | Consolidates entity call/signal span emission into a shared helper. |
| packages/durabletask-js/src/orchestration/page.ts | Simplifies hasMoreResults continuation token check. |
| packages/durabletask-js-azuremanaged/src/options.ts | Minor string construction cleanup for endpoint parsing. |
| packages/durabletask-js-azuremanaged/src/credential-factory.ts | Streamlines Workload Identity credential option building. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- ajv: upgraded to fix ReDoS vulnerability (GHSA-2g4f-4pwh-qvx6) - minimatch: upgraded to fix ReDoS vulnerabilities (GHSA-3ppc-4f35-3m26, GHSA-7r86-cg39-jmmj, GHSA-23c5-xmqv-rm74) - tar: upgraded to fix arbitrary file read/write vulnerability (GHSA-83g3-92jg-28cx) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Node.js >=22 is required, so ES2022 features like Error cause,
top-level await, and Array.at() are safe to use. This also restores
the { cause: err } option in parseJsonField() that was previously
removed due to the old target.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
YunchuWang
approved these changes
Feb 28, 2026
- Remove --runInBand from E2E test script to enable parallel file execution across Jest workers (~29 min → ~10 min estimated) - Add timeout-minutes: 20 to DTS E2E test step to prevent runaway tests - Switch npm install to npm ci for deterministic, faster CI installs - Fix Node.js version from 18.x to 22.x in pr-validation lint job to match the project's engines.node >= 22.0.0 requirement Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
YunchuWang
approved these changes
Feb 28, 2026
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.
Summary
What changed?
orchestration-executor.tsandhistory-event-converter.tsfor cleaner, more maintainable codetrace-helper.tsby reducing complexity and improving readabilitydurabletask-js-azuremanagedpb-helper.util.tsfor improved protobuf helper patternsruntime-orchestration-context.tsWhy is this change needed?
Issues / work items
Project checklist
AI-assisted code disclosure (required)
Was an AI tool used? (select one)
If AI was used:
AI verification (required if AI was used):
Testing
Automated tests
Manual validation (only if runtime/behavior changed)
Notes for reviewers