Skip to content

Fix ResolverTask running cleanup after scheduler completion#9984

Open
michaelstaib wants to merge 1 commit into
mainfrom
mst/issue-9972
Open

Fix ResolverTask running cleanup after scheduler completion#9984
michaelstaib wants to merge 1 commit into
mainfrom
mst/issue-9972

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 24, 2026 21:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a race where ResolverTask could mark itself complete with the WorkScheduler before running resolver cleanup tasks, allowing the shared OperationContext to be recycled while cleanup is still executing. It also adds a regression test that stresses concurrent entity resolution to catch the previously unobserved ObjectDisposedException scenario.

Changes:

  • Reordered ResolverTask finalization to run cleanup tasks before notifying the scheduler of completion (while still guaranteeing scheduler completion + pool return via finally).
  • Added a concurrency-focused Apollo Federation test that attempts to surface unobserved task exceptions caused by resolver context cloning/cleanup timing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/HotChocolate/Core/src/Types/Execution/Processing/Tasks/ResolverTask.Execute.cs Ensures cleanup executes before scheduler completion and always completes/returns the task even if cleanup faults.
src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/EntitiesResolverForObjectTests.cs Adds a stress/regression test for concurrent _entities resolution and unobserved task exceptions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +291 to +292
var deadline = DateTimeOffset.UtcNow.AddSeconds(8);
var workers = new Task[256];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants