Repository navigation
fix: preserve trailing events after continue-as-new - #386
Merged
Merged
Conversation
Buffer external events arriving after continue-as-new instead of completing abandoned listeners. Add real-batch public regressions and document opt-out and consumed-event behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 03e10c9a-ff91-410a-bf7c-84b1ca56e0f6
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix is consistent with carryover semantics and has comprehensive regression coverage.
0 open findings
What changed in this PR
Preserves trailing external events across continueAsNew(..., true) while maintaining existing routing semantics.
Changes:
- Prevents abandoned listeners from consuming post-continuation events.
- Adds executor and in-memory backend regression coverage.
- Documents carryover behavior and opt-out semantics.
| File | Description |
|---|---|
README.md |
Documents trailing-event retention. |
CHANGELOG.md |
Records the bug fix. |
orchestration-context.ts |
Expands API documentation. |
orchestration-executor.ts |
Buffers events after continuation. |
orchestration_executor.spec.ts |
Adds executor-level regressions. |
external-event-routing.spec.ts |
Adds public client/worker integration coverage. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
kaibocai (kaibocai)
approved these changes
Oct 9, 2026
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
Preserve external messages delivered after
continueAsNew(..., true)in the same work item instead of completing an abandoned listener in the previous execution.What changed?
saveEvents=falseopt-out in the API, README, and changelog.Why is this change needed?
whenAny([rotate, message])race could request continue-as-new whenrotatearrived, then lose a trailingmessageby completing the old listener without resuming the completed generator or buffering the payload.Issues / work items
Project checklist
CHANGELOG.mdAI-assisted code disclosure (required)
Was an AI tool used? (select one)
If AI was used:
AI verification (required if AI was used):
Testing
Automated tests
--json --outputFile=<local artifact>flags are omitted to avoid publishing internal paths.npm run test:unit --workspace @microsoft/durabletask-js -- --runTestsByPath test\external-event-routing.spec.ts test\orchestration_executor.spec.ts --testNamePattern "continue-as-new trailing events|routes trailing events|malformed trailing event"— failed as expected before the fix: 3 failures, 8 passes.npm run test:unit --workspace @microsoft/durabletask-js -- --runTestsByPath test\external-event-routing.spec.ts test\orchestration_executor.spec.ts test\in-memory-backend.spec.ts --testNamePattern "External event name routing|trailing event|continue-as-new|EVENTRAISED|EVENTSENT"— passed: 53 tests, 118 intentionally skipped by the selector.npm run test:unit --workspace @microsoft/durabletask-js— passed: 86 suites, 1,726 tests, no skipped tests.npm run build:core— passed, including core TypeScript compilation.npm exec --no -- eslint packages\durabletask-js\src\worker\orchestration-executor.ts packages\durabletask-js\src\task\context\orchestration-context.ts packages\durabletask-js\test\external-event-routing.spec.ts packages\durabletask-js\test\orchestration_executor.spec.ts— passed.npm exec --no -- prettier --check --end-of-line auto CHANGELOG.md packages\durabletask-js\src\task\context\orchestration-context.ts packages\durabletask-js\test\external-event-routing.spec.ts— passed. Added ranges in the remaining changed files were checked separately against existing Prettier; unrelated baseline style debt and CRLF endings were preserved.git diff --check origin/main...HEAD— passed.Manual validation (only if runtime/behavior changed)
TestOrchestrationClientandTestOrchestrationWorker, real repository in-memory backend and executor.saveEvents=falsecontrols. All nine runtime cases passed; workers and clients were stopped, backends reset, and no runtime timers remained.Notes for reviewers