Skip to content

Fix Fusion gateway never detecting stalled subscription streams - #10281

Merged
michaelstaib merged 3 commits into
mainfrom
mst/fusion-subscription-read-timeout
Aug 22, 2026
Merged

michaelstaib merged 3 commits into
mainfrom
mst/fusion-subscription-read-timeout

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

Copilot AI lite review requested due to automatic review settings August 22, 2026 04: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 addresses a reliability gap in Fusion gateway subscriptions where a stalled (but still connected) subgraph streaming response could cause the gateway to wait indefinitely. It introduces a configurable per-read timeout on streaming subscription responses (SSE / JSON Lines) so that “no bytes received” is detected and surfaced as a terminal subscription error, while still treating keep-alives as activity.

Changes:

  • Add ReadTimeoutStream and thread the readTimeout parameter through GraphQLHttpResponse streaming readers (SSE + JSONL) and the Fusion HTTP source schema subscription client.
  • Introduce SubscriptionReadTimeout configuration (default 60s, supports Timeout.InfiniteTimeSpan) and propagate it through Fusion gateway builder APIs and test harnesses.
  • Adjust subscription/event-stream execution nodes to emit a single terminal error result on failed reads/decodes (with improved arena ownership handling), and add/extend tests for stall detection and keep-alive behavior.

Reviewed changes

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

Show a summary per file
File Description
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Transport/Http/SseReaderTests.cs Update SSE reader tests for new readTimeout constructor parameter.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Subscriptions/EventStreamBrokerReadFailureTests.cs Extend tests to assert terminal error-result behavior on broker read failure and continued operation on decode failure.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Clients/HttpSourceSchemaClientConfigurationTests.cs New tests for default/disabled/out-of-range SubscriptionReadTimeout configuration.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/FusionTestBase.cs Plumb SubscriptionReadTimeout through composite schema creation helper options.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/FusionTestBase.CreateSourceSchema.cs Add subscriptionReadTimeout support to source schema test server creation helpers.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/CancellationTests.cs Add coverage for stalled stream detection vs keep-alives, and client disconnect teardown across SSE/JSONL.
src/HotChocolate/Fusion/src/Fusion.Execution/HotChocolate.Fusion.Execution.csproj Include ReadTimeoutStream.cs in Fusion.Execution build.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/OperationPlanExecutor.cs Ensure per-event CTS is refreshed if canceled between events due to error/null-propagation.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/OperationExecutionNode.cs Emit a terminal error result on transport read failures and tighten arena ownership handling.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/EventStreamExecutionNode.cs Emit terminal error result on broker read failure; keep subscription alive on per-message decode failure; improve arena handling.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Clients/HttpSourceSchemaClientConfiguration.cs Add configurable SubscriptionReadTimeout with validation and a 60s default.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Clients/HttpSourceSchemaClient.cs Apply SubscriptionReadTimeout to streaming response reads during subgraph subscriptions.
src/HotChocolate/Fusion/src/Fusion.Execution/DependencyInjection/CoreFusionGatewayBuilderExtensions.SourceSchemaClients.cs Add optional subscriptionReadTimeout to gateway builder configuration APIs and docs.
src/HotChocolate/AspNetCore/test/Transport.Http.Tests/ReadTimeoutStreamTests.cs New tests validating timeout behavior, cancellation behavior, and range checks.
src/HotChocolate/AspNetCore/src/Transport.Http/Sse/SseReader.cs Wrap response stream with ReadTimeoutStream for Fusion streaming reads.
src/HotChocolate/AspNetCore/src/Transport.Http/ReadTimeoutStream.cs New stream wrapper enforcing per-read timeouts with clear timeout exceptions.
src/HotChocolate/AspNetCore/src/Transport.Http/JsonLines/JsonLinesReader.cs Wrap response stream with ReadTimeoutStream for Fusion JSONL streaming reads.
src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpResponse.cs Add readTimeout overload for Fusion streaming reads and validate timeout range.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +94 to +101
catch (Exception) when (timeoutSource.IsCancellationRequested
&& !cancellationToken.IsCancellationRequested
&& !_disposed)
{
throw new TimeoutException(
"No data (including keep-alive messages) was received on the response stream "
+ $"within the configured read timeout of {FormatTimeout(_timeout)}.");
}
var configuration = new HttpSourceSchemaClientConfiguration("A", s_baseAddress);

// assert
Assert.Equal(TimeSpan.FromSeconds(60), configuration.SubscriptionReadTimeout);
@michaelstaib
michaelstaib merged commit dbbb61a into main Aug 22, 2026
9 of 10 checks passed
@michaelstaib
michaelstaib deleted the mst/fusion-subscription-read-timeout branch August 22, 2026 12:37
This was referenced Aug 29, 2026
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.

Fusion: a subgraph subscription that stops responding without closing the connection is never detected — the gateway waits indefinitely

2 participants