Skip to content

Improve console logs error handling #10012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Jun 24, 2025

Description

Fix this error in the dashboard:

Status(StatusCode="Internal", Detail="Error reading next message. HttpProtocolException: The HTTP/2 server sent invalid data on the connection. HTTP/2 error code 'PROTOCOL_ERROR' (0x1). (HttpProtocolError)", DebugException="System.Net.Http.HttpProtocolException: The HTTP/2 server sent invalid data on the connection. HTTP/2 error code 'PROTOCOL_ERROR' (0x1). (HttpProtocolError)")

at Grpc.Net.Client.Internal.HttpContentClientStreamReader`2.MoveNextCore(CancellationToken cancellationToken)
   at Grpc.Net.Client.Internal.Retry.RetryCallBaseClientStreamReader`2.MoveNext(CancellationToken cancellationToken)
   at Grpc.Core.AsyncStreamReaderExtensions.ReadAllAsyncCore[T](IAsyncStreamReader`1 streamReader, CancellationToken cancellationToken)+MoveNext()
   at Grpc.Core.AsyncStreamReaderExtensions.ReadAllAsyncCore[T](IAsyncStreamReader`1 streamReader, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at Aspire.Dashboard.Model.DashboardClient.<>c__DisplayClass34_0.<<Aspire-Dashboard-Model-IDashboardClient-SubscribeConsoleLogs>b__0>d.MoveNext() in /_/src/Aspire.Dashboard/ResourceService/DashboardClient.cs:line 487
--- End of stack trace from previous location ---
   at Aspire.Dashboard.Model.DashboardClient.<>c__DisplayClass34_0.<<Aspire-Dashboard-Model-IDashboardClient-SubscribeConsoleLogs>b__0>d.MoveNext() in /_/src...

I believe the error happens when the user canceling watching console logs at just the wrong time (i.e. navigates away from the page or switches to a different resource) while data is received.

Fix is to handle the error instead of letting it bubble up to Blazor. Log error and set status on page when error occurs. Only do this when subscription is not already canceled.

Contributes to #9537

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

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 improves error handling for console logs by capturing and logging errors that occur during log reading, preventing unhandled exceptions from bubbling up in Blazor. Key changes include new tests validating error handling, updates to resource localization to include a new error message, and enhanced error catching in the ConsoleLogs component.

Reviewed Changes

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

File Description
tests/Aspire.Dashboard.Components.Tests/Pages/ConsoleLogsTests.cs Added tests to validate error handling when reading logs and after component disposal.
src/Aspire.Dashboard/Resources/xlf/*.xlf and src/Aspire.Dashboard/Resources/ConsoleLogs.resx Added new error message resource ("Error watching logs") for localized error handling.
src/Aspire.Dashboard/ResourceService/DashboardClient.cs Updated structured logging for missing configuration using parameterized messages.
src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs Added a catch block to log errors and update page status during log subscription errors.
Files not reviewed (1)
  • src/Aspire.Dashboard/Resources/ConsoleLogs.Designer.cs: Language not supported

@JamesNK JamesNK force-pushed the jamesnk/subscribelogs-error branch from f8880b3 to 5dd32ad Compare June 24, 2025 07:26
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.

1 participant