Commit 71db02c
committed
fix: guard sub-orchestration completion handler against missing pending tasks
Refactor handleSubOrchestrationCompleted to delegate to handleCompletedTask,
matching the pattern used by handleSubOrchestrationFailed -> handleFailedTask
and handleTaskCompleted -> handleCompletedTask.
Before this fix, handleSubOrchestrationCompleted called ctx.resume()
unconditionally, even when no matching pending task was found. This differs
from handleCompletedTask (the activity completion handler), which correctly
returns early with a warning log when no matching task exists.
The unconditional resume() could advance the generator incorrectly if
_previousTask happens to be complete from an unrelated event. Additionally,
orphaned sub-orchestration completion events were silently dropped without
any diagnostic logging, unlike the activity handler.
This change:
- Adds the missing guard clause (returns early when no task found)
- Adds warning logging for unexpected events (via WorkerLogs)
- Adds isEmpty normalization for empty results (consistent with activity handler)
- Reduces code duplication by reusing handleCompletedTask
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 29455dd commit 71db02c
2 files changed
Lines changed: 32 additions & 19 deletions
File tree
- packages/durabletask-js
- src/worker
- test
Lines changed: 5 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
408 | 394 | | |
409 | 395 | | |
410 | 396 | | |
| |||
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
573 | 600 | | |
574 | 601 | | |
575 | 602 | | |
| |||
0 commit comments