Skip to content

[copilot-finds] Bug: Worker execution wrappers missing .catch() cause unhandled promise rejections that crash the process #250

@github-actions

Description

@github-actions

Problem

The _executeOrchestrator(), _executeActivity(), and _executeEntity() wrapper methods in task-hub-grpc-worker.ts (lines 612-622, 800-810, 882-893) create fire-and-forget promises tracked in _pendingWorkItems. These promises only have .finally() for cleanup but no .catch() handler.

The corresponding internal methods (_executeOrchestratorInternal, _executeActivityInternal, _executeEntityInternal) throw errors before their inner try/catch blocks when validation fails (e.g., missing instanceId). These early throws produce unhandled promise rejections.

Root Cause

In JavaScript, .finally() does not mark a rejection as handled — only .catch() does. So when:

  1. _executeOrchestratorInternal throws at line 635 (missing instanceId)
  2. _executeActivityInternal throws at line 823 (missing orchestration instance)
  3. _executeEntityInternal throws at line 916 (missing instanceId)

...the rejection propagates as unhandled.

Impact

Severity: High. In Node.js 22+ (the minimum required version for this SDK), unhandled promise rejections terminate the process by default. A single malformed work item from the sidecar (missing instanceId) will crash the entire worker, taking down all in-flight orchestrations, activities, and entities.

Proposed Fix

Add .catch() handlers to all three wrapper methods that log the error via the existing WorkerLogs infrastructure instead of letting the rejection go unhandled. The .finally() cleanup is preserved to ensure _pendingWorkItems tracking remains correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    copilot-findsFindings from daily automated code review agent

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions