fix: clear stale in-memory purge queue entries#285
Open
YunchuWang wants to merge 1 commit into
Open
Conversation
InMemory purge removed instance state but left queued IDs in orchestrationQueue and orchestrationQueueSet. Clear both structures during purge so re-created instances with the same ID can enqueue and process. Fixes #249 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a correctness issue in the in-memory testing backend where purge() could leave behind stale orchestration work-queue bookkeeping, preventing a re-created orchestration with the same instance ID from ever being enqueued/processed.
Changes:
- Updated
InMemoryOrchestrationBackend.purge()to remove the instance ID fromorchestrationQueueSetandorchestrationQueue. - Added a regression test that reproduces the “late enqueue → purge → recreate same ID hangs” scenario and verifies the fix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/durabletask-js/src/testing/in-memory-backend.ts | Ensures purge() also cleans up the in-memory orchestration queue/set to avoid stale dedupe entries. |
| packages/durabletask-js/test/in-memory-backend.spec.ts | Adds a regression test covering purge queue cleanup and successful re-creation + completion of the same instance ID. |
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
Fixes a stale work-queue entry bug in the in-memory testing backend purge path.
InMemoryOrchestrationBackend.purge()previously removed the orchestration instance state, state waiters, and instance timers, but it did not remove the instance ID fromorchestrationQueueororchestrationQueueSet. BecauseenqueueOrchestration()usesorchestrationQueueSetas a deduplication guard, a purged instance could leave behind a stale set entry that caused a newly created orchestration with the same instance ID to silently skip enqueueing.Why this matters
The trigger scenario is:
orchestrationQueueSetentry makesenqueueOrchestration()a no-op, so the new instance never gets processed and appears to hang.This affects the in-memory testing infrastructure and can make tests silently stall when they purge and recreate an orchestration with the same ID.
Fix
purge()now removes the instance ID from both queue structures before deleting waiters/timers:orchestrationQueueSet.orchestrationQueueif present.This mirrors the queue cleanup behavior already present in
reset()while preserving the rest of the purge semantics.Tests
Added a regression test that:
Validation run:
npm run build:corenpx eslint packages\durabletask-js\src\testing\in-memory-backend.ts packages\durabletask-js\test\in-memory-backend.spec.tsnpx jest --runInBand --runTestsByPath .\test\in-memory-backend.spec.ts --testNamePattern "should clear stale queued work"npx jest --runInBandFixes #249