Skip to content

Conversation

halter73
Copy link
Contributor

@halter73 halter73 commented Oct 2, 2025

This works around the breaking change to BackgroundService in dotnet/runtime#116283 which launches ExecuteAsync using Task.Run.

Fixes #823

This works around the breaking change to BackgroundService in
dotnet/runtime#116283 which launches
ExecuteAsync using Task.Run
Copy link
Contributor

@Copilot 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 moves options validation from the ExecuteAsync method to the constructor in IdleTrackingBackgroundService to address a breaking change in .NET 10 where BackgroundService launches ExecuteAsync using Task.Run, potentially causing validation exceptions to be lost.

  • Refactored IdleTrackingBackgroundService to use traditional constructor with field assignments instead of primary constructor
  • Moved validation logic from ExecuteAsync to constructor to ensure early failure
  • Removed conditional compilation directives that were skipping tests on .NET 10

Reviewed Changes

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

File Description
IdleTrackingBackgroundService.cs Converted from primary constructor to traditional constructor with field assignments and moved validation logic
StreamableHttpServerConformanceTests.cs Removed .NET 10 conditional compilation that was skipping validation tests
Comments suppressed due to low confidence (1)

src/ModelContextProtocol.AspNetCore/IdleTrackingBackgroundService.cs:1

  • The validation logic should validate the options before assigning them to fields. Move these validation calls to occur before the field assignments at lines 28-31 to fail fast if invalid options are provided.
using Microsoft.Extensions.Hosting;

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.

HTTP server transport can throw TaskCancelledException when running .NET 10 under certain circumstances

2 participants