Skip to content

Fix resource leak in AppComponentTest by disposing service scope#105

Merged
sfmskywalker merged 3 commits intoenh/102from
copilot/sub-pr-104
Dec 24, 2025
Merged

Fix resource leak in AppComponentTest by disposing service scope#105
sfmskywalker merged 3 commits intoenh/102from
copilot/sub-pr-104

Conversation

Copy link
Contributor

Copilot AI commented Dec 24, 2025

The AppComponentTest base class creates an IServiceScope but never disposes it, causing resource leaks in the test suite.

Changes:

  • Added Scope?.Dispose() in the Dispose() method to properly clean up service scopes
  • Used null-conditional operator to handle potential multiple disposal calls safely
public void Dispose()
{
    OnDispose();
    Scope?.Dispose();  // Added
    GC.SuppressFinalize(this);
}

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

Copilot AI and others added 2 commits December 24, 2025 20:38
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Quartz.NET jobs resilience implementation based on feedback Fix resource leak in AppComponentTest by disposing service scope Dec 24, 2025
Copilot AI requested a review from sfmskywalker December 24, 2025 20:43
@sfmskywalker sfmskywalker marked this pull request as ready for review December 24, 2025 20:46
Copilot AI review requested due to automatic review settings December 24, 2025 20:46
@sfmskywalker sfmskywalker merged commit edb24a9 into enh/102 Dec 24, 2025
3 checks passed
@sfmskywalker sfmskywalker deleted the copilot/sub-pr-104 branch December 24, 2025 20:46
Copy link
Contributor

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

This PR addresses a resource leak in the AppComponentTest base class by adding disposal of the IServiceScope instance that is created but never cleaned up.

  • Added Scope?.Dispose() call in the Dispose() method to properly release service scope resources
  • Used null-conditional operator for safe disposal handling

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

public void Dispose()
{
OnDispose();
Scope?.Dispose();
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

This change may cause test runner hangs. There's an identical AppComponentTest class in test/modules/servicebus/Elsa.ServiceBus.AzureServiceBus.ComponentTests/Abstractions/AppComponentTest.cs that has a similar Scope property, but the disposal is commented out with an explicit warning: "Disposing the Scope here and in other places where it is created somehow seems to cause the test runner to hang when running other test projects."

Before merging this change, please verify that disposing the Scope in this test class doesn't cause similar hanging issues. Consider running the full test suite, including other test projects, to ensure this doesn't introduce instability.

Suggested change
Scope?.Dispose();
// Do not dispose Scope here. Disposing the Scope in similar component test base classes
// has been observed to cause the test runner to hang when running other test projects.

Copilot uses AI. Check for mistakes.
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.

3 participants