Skip to content

fix: clear orchestrationQueueSet in InMemoryOrchestrationBackend.reset()#133

Open
YunchuWang wants to merge 1 commit intomainfrom
copilot-finds/bug/fix-inmemory-backend-reset-orchestration-queue-set
Open

fix: clear orchestrationQueueSet in InMemoryOrchestrationBackend.reset()#133
YunchuWang wants to merge 1 commit intomainfrom
copilot-finds/bug/fix-inmemory-backend-reset-orchestration-queue-set

Conversation

@YunchuWang
Copy link
Member

The reset() method clears the orchestrationQueue array but does not clear the orchestrationQueueSet. When an orchestration is created and reset() is called before the orchestration is dequeued, the Set retains the stale instance ID. Any subsequent createInstance() call with the same ID after reset is silently skipped by enqueueOrchestration() because the Set still reports the ID as present.

This causes the orchestration to never be processed.

Summary

What changed?

Why is this change needed?

Issues / work items

  • Resolves #
  • Related #

Project checklist

  • Release notes are not required for the next release
    • Otherwise: Notes added to CHANGELOG.md
  • Backport is not required
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • All required tests have been added/updated (unit tests, E2E tests)
  • Breaking change?
    • If yes:
      • Impact:
      • Migration guidance:

AI-assisted code disclosure (required)

Was an AI tool used? (select one)

  • No
  • Yes, AI helped write parts of this PR (e.g., GitHub Copilot)
  • Yes, an AI agent generated most of this PR

If AI was used:

  • Tool(s):
  • AI-assisted areas/files:
  • What you changed after AI output:

AI verification (required if AI was used):

  • I understand the code and can explain it
  • I verified referenced APIs/types exist and are correct
  • I reviewed edge cases/failure paths (timeouts, retries, cancellation, exceptions)
  • I reviewed concurrency/async behavior
  • I checked for unintended breaking or behavior changes

Testing

Automated tests

  • Result: Passed / Failed (link logs if failed)

Manual validation (only if runtime/behavior changed)

  • Environment (OS, Node.js version, components):
  • Steps + observed results:
    1.
    2.
    3.
  • Evidence (optional):

Notes for reviewers

  • N/A

The reset() method clears the orchestrationQueue array but does not clear
the orchestrationQueueSet. When an orchestration is created and reset()
is called before the orchestration is dequeued, the Set retains the stale
instance ID. Any subsequent createInstance() call with the same ID after
reset is silently skipped by enqueueOrchestration() because the Set
still reports the ID as present.

This causes the orchestration to never be processed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 5, 2026 02:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a state-reset bug in the in-memory testing backend where reset() cleared the orchestration queue array but left its de-duplication Set populated, preventing re-enqueue of the same instance ID after a reset.

Changes:

  • Clear orchestrationQueueSet in InMemoryOrchestrationBackend.reset().
  • Add a regression test that reproduces “instance ID reuse after reset” and verifies the orchestration is processed successfully.

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 Clears the queue de-duplication set during reset() to fully reset queueing state.
packages/durabletask-js/test/in-memory-backend.spec.ts Adds a regression test ensuring instance IDs can be reused after backend.reset() when an item was still queued.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants