Skip to content

fix: clean up observableToAsyncIterable state when observable completes#8057

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-action-job-issue
Draft

fix: clean up observableToAsyncIterable state when observable completes#8057
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-action-job-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 18, 2026

The Leak Test CI job was failing non-deterministically because observableToAsyncIterable never released its internal queues and subscription when the observable sent a done: true signal — leaving those references alive past the end of the test, causing Jest's --detectLeaks to flag the test suite.

Changes

  • pullValue(): When shifting a done: true element off pushQueue, call emptyQueue() before resolving — clearing pullQueue, pushQueue, unsubscribing, and setting listening = false immediately rather than waiting for the iterator to be explicitly return()ed.
  • pushDone(): After resolving a pending consumer (pulled from pullQueue) with the done signal, call emptyQueue() to release any remaining state.

The forward references to emptyQueue are safe: both code paths are only reachable after the iterator has been returned to the caller, which is after emptyQueue is defined.

// Before: after iterator.next() resolves with {done: true},
// pullQueue/pushQueue/subscription/listening were still held
// by the iterator's closures until explicit return() or GC.

// After: emptyQueue() is called eagerly when the done signal
// is delivered, releasing all internal references immediately.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 18, 2026

🦋 Changeset detected

Latest commit: 6773282

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@ardatan/relay-compiler Patch
@graphql-tools/graphql-tag-pluck Patch
@graphql-tools/relay-operation-optimizer Patch
@graphql-tools/code-file-loader Patch
@graphql-tools/git-loader Patch
@graphql-tools/github-loader Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

…letes

Co-authored-by: ardatan <20847995+ardatan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix action job issue fix: clean up observableToAsyncIterable state when observable completes Mar 18, 2026
Copilot AI requested a review from ardatan March 18, 2026 01:53
@github-actions
Copy link
Copy Markdown
Contributor

💻 Website Preview

The latest changes are available as preview in: https://pr-8057.graphql-tools.pages.dev

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