Problem
processNewEventsForTracing() in packages/durabletask-js/src/tracing/trace-helper.ts (line 464–478) builds its scheduling-event lookup maps only from pastEvents, not from newEvents. When a task is scheduled and completes within the same event batch (both events arrive as new events), the corresponding tracing span is silently missing.
This affects:
- Activities:
TaskScheduled + TaskCompleted/TaskFailed in the same batch
- Sub-orchestrations:
SubOrchestrationInstanceCreated + SubOrchestrationInstanceCompleted/SubOrchestrationInstanceFailed in the same batch
- Timers:
TimerCreated + TimerFired in the same batch
Root Cause
The lookup maps (taskScheduledEvents, subOrchCreatedEvents, timerCreatedEvents) are populated exclusively from pastEvents:
for (const event of pastEvents) {
// ... populates maps
}
When a scheduling event appears in newEvents instead of pastEvents, it is never indexed. The subsequent completion event in newEvents looks up the scheduling event by ID and gets undefined, causing the span to be silently skipped.
Proposed Fix
Also iterate over newEvents when building the lookup maps, so scheduling events from both past and new event batches are indexed.
Impact
- Severity: Medium — affects tracing/observability correctness, not data or execution correctness
- Scenarios affected: Fast-completing activities, sub-orchestrations, or zero-delay timers where both the scheduling and completion events are delivered in the same event batch
- Symptoms: Missing spans in distributed traces, making debugging of quick-executing tasks harder
Problem
processNewEventsForTracing()inpackages/durabletask-js/src/tracing/trace-helper.ts(line 464–478) builds its scheduling-event lookup maps only frompastEvents, not fromnewEvents. When a task is scheduled and completes within the same event batch (both events arrive as new events), the corresponding tracing span is silently missing.This affects:
TaskScheduled+TaskCompleted/TaskFailedin the same batchSubOrchestrationInstanceCreated+SubOrchestrationInstanceCompleted/SubOrchestrationInstanceFailedin the same batchTimerCreated+TimerFiredin the same batchRoot Cause
The lookup maps (
taskScheduledEvents,subOrchCreatedEvents,timerCreatedEvents) are populated exclusively frompastEvents:When a scheduling event appears in
newEventsinstead ofpastEvents, it is never indexed. The subsequent completion event innewEventslooks up the scheduling event by ID and getsundefined, causing the span to be silently skipped.Proposed Fix
Also iterate over
newEventswhen building the lookup maps, so scheduling events from both past and new event batches are indexed.Impact