Skip to content

[copilot-finds] Bug: TestOrchestrationWorker processing loop crashes when completeOrchestration fails in error handler #174

@github-actions

Description

@github-actions

Problem

InMemoryOrchestrationBackend.completeOrchestration() throws an Error when the target instance does not exist (e.g., after backend.reset() or purgeOrchestration()), but the sibling method completeActivity() silently returns for the same scenario. This inconsistency causes TestOrchestrationWorker.processOrchestration() to crash when its catch block calls completeOrchestration on a purged instance.

File: packages/durabletask-js/src/testing/in-memory-backend.ts, line 257
File: packages/durabletask-js/src/testing/test-worker.ts, lines 155-158

Root Cause

In in-memory-backend.ts:

  • completeOrchestration() (line 257): throw new Error(...) when instance not found
  • completeActivity() (line 311): silently returns when instance not found

In test-worker.ts, processOrchestration() has a catch block that calls completeOrchestration to report failures. If the instance was deleted between scheduling and completion (e.g., via reset()), the throw propagates out of the catch block, crashing runProcessingLoop(). The worker silently stops processing all subsequent work items.

Proposed Fix

  1. Root cause: Change completeOrchestration to return silently when the instance is not found, consistent with completeActivity.
  2. Defense-in-depth: Wrap the catch block's completeOrchestration call in a nested try-catch so the worker survives even if completeOrchestration throws for other reasons.

Impact

  • Severity: Medium — affects testing infrastructure only (not production runtime)
  • Scenarios affected: Any test that calls backend.reset() or purgeOrchestration() while orchestrations are in flight. The worker stops processing silently, causing subsequent test assertions to hang or time out with confusing errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    copilot-findsFindings from daily automated code review agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions