Skip to content

Dispose type module change monitor on failed executor creation - #9902

Merged
tobias-tengler merged 2 commits into
mainfrom
tte/cleanup-typemodule-registration-if-executor-creation-fails
Jun 11, 2026
Merged

tobias-tengler merged 2 commits into
mainfrom
tte/cleanup-typemodule-registration-if-executor-creation-fails

Conversation

@tobias-tengler

@tobias-tengler tobias-tengler commented Jun 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #9901

Copilot AI review requested due to automatic review settings June 11, 2026 15:35

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 addresses Hot Chocolate issue #9901 where failed executor rebuilds could leak TypeModule.TypesChanged subscriptions, leading to exponentially increasing TypeModule.CreateTypesAsync() invocations after repeated OnTypesChanged() signals. The core fix ensures the type module change monitor is disposed when executor creation fails, and adds a regression test to detect subscription leaks when a type instance is registered.

Changes:

  • Dispose TypeModuleChangeMonitor (and schema service provider) when request executor creation fails, preventing leaked event subscriptions.
  • Add a regression test covering repeated OnTypesChanged() triggers with a registered type instance to ensure CreateTypesAsync() calls don’t grow exponentially.

Reviewed changes

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

File Description
src/HotChocolate/Core/src/Types/Execution/RequestExecutorManager.cs Wrap executor creation in try/catch and dispose the change monitor (and schema services) on failure to prevent leaked TypesChanged subscriptions.
src/HotChocolate/Core/test/Execution.Tests/RequestExecutorManagerTests.cs Adds a regression test that triggers OnTypesChanged() repeatedly and asserts CreateTypesAsync() calls don’t grow beyond the number of triggers.

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

Comment thread src/HotChocolate/Core/src/Types/Execution/RequestExecutorManager.cs
Comment thread src/HotChocolate/Core/test/Execution.Tests/RequestExecutorManagerTests.cs Outdated
Comment thread src/HotChocolate/Core/src/Types/Execution/RequestExecutorManager.cs Dismissed
@tobias-tengler
tobias-tengler merged commit 57e3032 into main Jun 11, 2026
144 checks passed
@tobias-tengler
tobias-tengler deleted the tte/cleanup-typemodule-registration-if-executor-creation-fails branch June 11, 2026 16:20
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.

Exponentially increasing amount of calls to TypeModule.CreateTypesAsync() after each OnTypesChanged()

2 participants