Open
Conversation
Add work item filters to the GetWorkItemsRequest, matching the .NET SDK's DurableTaskWorkerWorkItemFilters feature. This allows workers to tell the sidecar which orchestrations, activities, and entities they can handle, enabling more efficient work item routing. Changes: - Update orchestrator_service.proto with WorkItemFilters, OrchestrationFilter, ActivityFilter, and EntityFilter message types (field 11 on GetWorkItemsRequest) - Regenerate gRPC stubs from updated proto definitions - Add WorkItemFilters TypeScript interfaces and conversion functions - Add Registry.getOrchestratorNames/getActivityNames/getEntityNames methods - Auto-generate filters from registry in TaskHubGrpcWorker.internalRunWorker - Support explicit filters via workItemFilters option on TaskHubGrpcWorkerOptions - Support null to explicitly disable filtering (receive all work items) - Add useWorkItemFilters() builder method to DurableTaskAzureManagedWorkerBuilder - Export new types from package index - Add 36 unit tests covering conversion, generation, versioning integration, and end-to-end registry-to-gRPC flows
packages/durabletask-js/src/proto/orchestrator_service_pb.js
Dismissed
Show dismissed
Hide dismissed
packages/durabletask-js/src/proto/orchestrator_service_pb.js
Dismissed
Show dismissed
Hide dismissed
Contributor
There was a problem hiding this comment.
Pull request overview
Adds work item filtering support to the DurableTask JS worker so a worker can ask the sidecar to only stream orchestrations/activities/entities it can handle (optionally including version constraints), and exposes helpers to generate/convert these filters.
Changes:
- Introduces
WorkItemFilterstypes plus helpers to generate filters from theRegistryand convert them into protobuf messages. - Extends
TaskHubGrpcWorker(and the Azure Managed worker builder) with aworkItemFiltersoption (undefined= auto-generate,null= disable filtering). - Updates the protocol (
GetWorkItemsRequest) and generated protobuf JS/TS stubs to includeWorkItemFilters, and adds comprehensive unit tests for filter generation/conversion and registry name getters.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/durabletask-js/test/work-item-filters.spec.ts | New unit tests for filter conversion/generation, worker option wiring, and registry name getters. |
| packages/durabletask-js/src/worker/work-item-filters.ts | New SDK-level filter model + registry→filters generator + filters→protobuf converter. |
| packages/durabletask-js/src/worker/task-hub-grpc-worker.ts | Sends workItemFilters on GetWorkItemsRequest (auto-generated by default; null disables). |
| packages/durabletask-js/src/worker/registry.ts | Adds name getter APIs used for filter auto-generation. |
| packages/durabletask-js/src/proto/orchestrator_service_pb.js | Regenerated protobuf JS: adds WorkItemFilters and related messages + request field. |
| packages/durabletask-js/src/proto/orchestrator_service_pb.d.ts | Regenerated protobuf TS types for WorkItemFilters and new request field. |
| packages/durabletask-js/src/index.ts | Exports the new filter APIs from the public package surface. |
| packages/durabletask-js-azuremanaged/src/worker-builder.ts | Adds useWorkItemFilters() builder method and forwards filters to core worker. |
| internal/protocol/protos/orchestrator_service.proto | Adds WorkItemFilters messages and workItemFilters field to GetWorkItemsRequest. |
You can also share your feedback on Copilot code review. Take the survey.
- Change orchestrator test helpers to direct async generator functions instead of factory functions returning generators (Copilot review) - Extract _buildGetWorkItemsRequest() from internalRunWorker() for testability and add 4 unit tests verifying filter request building: auto-generate, null (disabled), explicit filters, and Strict versioning (Copilot review)
- Add 4 e2e tests in test/e2e-azuremanaged/work-item-filters.spec.ts covering: auto-generated filters, explicit filters, and disabled filters (null) - Add examples/work-item-filters/ demonstrating all three filter modes - All tests verified passing against DTS emulator (localhost:8080)
Member
Author
E2E Test & Example Results (DTS Emulator)All tests and examples ran successfully against the DTS emulator ( E2E Test Results (
|
The explicit filter test was functionally identical to the auto-generated filter test since it provided the same names that auto-generation would produce.
- Add test for auto-generated filters with Strict versioning strategy - Add test for explicit versioned filters via useWorkItemFilters() - Both tests verified passing against DTS emulator and real DTS scheduler
- Unskip 'should not dispatch orchestration that is not in the filter' test (server-side filter enforcement now works on DTS scheduler) - Add 'should not dispatch orchestration when name matches but version does not' test verifying versioned filter enforcement - All 6 e2e tests verified passing against DTS scheduler (East Asia) - Example verified passing against DTS scheduler
Member
Author
Updated E2E Test Results (DTS Scheduler — East Asia)All tests and example verified against real DTS scheduler ( E2E Test Results (
|
- Register both orchA and orchB but only include orchA in the explicit filter - Schedule orchB and verify it stays PENDING (not dispatched to worker) - Verified passing against DTS scheduler (East Asia)
Remove two tests that overlap with existing orchestration e2e tests (auto-generated filters are now the default behavior for all workers). Remaining 5 tests focus on filter-specific scenarios: disabled filters, explicit versioned filters, and filter enforcement (name/version mismatch, registered-but-excluded).
Skip the 'Filtered-out work items' test group since the DTS emulator (used in CI) does not yet enforce server-side work item filters. These tests pass against a real DTS scheduler but fail against the emulator which dispatches all work items regardless of filters.
Explicitly lowercase entity names in toGrpcWorkItemFilters() to match .NET SDK behavior where entity names are normalized to lowercase in the backend. This ensures explicit user-provided entity filters are also lowercased, not just auto-generated ones from the registry.
The disabled filters (null) scenario produces the same observable result as auto-generated filters. Keep only auto-generated and explicit filter scenarios which demonstrate distinct behaviors.
Update SOURCE_COMMIT to track upstream commit 1caadbd which already includes the WorkItemFilters proto definitions. Proto content is identical to our manual addition — confirms alignment with the shared proto repo.
The auto-generated work item filters include the worker's version when VersionMatchStrategy.Strict is configured. This causes the sidecar to filter out version-mismatched orchestrations server-side, preventing the SDK's local FailureStrategy logic from running. Disable filters in createWorkerWithVersioning() so version mismatches are handled locally.
…t test The slow activities may not be dispatched/executed before the orchestrator catches the whenAll failure and completes. Whether they run is purely timing-dependent, so asserting their counter is inherently flaky. The test's purpose is to verify the orchestration stays COMPLETED after fail-fast, which the remaining assertions already cover.
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
Implements the work item filter feature in the JavaScript/TypeScript SDK to match the .NET SDK's
DurableTaskWorkerWorkItemFilters(introduced in v1.21.0, PR #616).Work item filters allow workers to tell the sidecar which orchestrations, activities, and entities they are configured to handle. The sidecar then only dispatches matching work items to that worker, enabling more efficient routing in multi-worker deployments.
Behavior
workItemFiltersnot set)workItemFilters: {...})workItemFilters: null)Versioning Integration
When
VersionMatchStrategy.Strictis configured, the auto-generated filters include the worker's version string. Other strategies (None,CurrentOrOlder) produce empty version arrays (match all versions).Entity filters never include versions (matching .NET SDK behavior).
Changes
Proto Layer
orchestrator_service.protowithWorkItemFilters,OrchestrationFilter,ActivityFilter,EntityFiltermessage typesworkItemFiltersfield (field 11) toGetWorkItemsRequestCore SDK (
@microsoft/durabletask-js)work-item-filters.ts— TypeScript interfaces (WorkItemFilters,OrchestrationWorkItemFilter,ActivityWorkItemFilter,EntityWorkItemFilter),generateWorkItemFiltersFromRegistry()for auto-generation, andtoGrpcWorkItemFilters()for protobuf conversiongetOrchestratorNames(),getActivityNames(),getEntityNames()methodsworkItemFiltersoption toTaskHubGrpcWorkerOptions; filters are built and attached toGetWorkItemsRequestininternalRunWorker()Azure Managed Package (
@microsoft/durabletask-js-azuremanaged)useWorkItemFilters()builder method toDurableTaskAzureManagedWorkerBuilderTaskHubGrpcWorkerconstructorTesting
36 new unit tests covering:
toGrpcWorkItemFilters— empty filters, single/multiple orchestration/activity/entity filters, version handling, mixed filtersgenerateWorkItemFiltersFromRegistry— empty registry, auto-detection of names, versioning strategy integration (Strict/None/CurrentOrOlder), named registrations, entity name lowercasing, version array isolationTaskHubGrpcWorker— accepts explicit filters, null filters, undefined (auto-generate), combined with versioningRegistryname getter methodsAll 959 existing tests + 36 new tests pass (60 test suites, 0 failures).
Reference
DurableTaskWorkerWorkItemFilters.cs,DurableTaskWorkerWorkItemFiltersExtension.cs