Skip to content

Fix EventSource never receiving the SSE complete event - #10462

Merged
glen-84 merged 1 commit into
mainfrom
gai/sse-complete-empty-data-field
Oct 1, 2026
Merged

glen-84 merged 1 commit into
mainfrom
gai/sse-complete-empty-data-field

Conversation

@glen-84

@glen-84 glen-84 commented Oct 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Every text/event-stream response ended with event: complete and no data: field. The browser EventSource API does not dispatch an event without data, so an EventSource client never saw complete: when the response ended it reconnected after its retry delay (3 s in Chromium) and the server executed the operation again, for as long as the page stayed open.
  • The complete event now carries an empty data: field, as the GraphQL over SSE RFC asks and the graphql-sse reference server writes. Clients that parse the stream themselves, including the 15.1 and 16.x readers in GraphQLHttpClient and the Fusion subgraph client, accept both forms, so a gateway and subgraph on different versions are unaffected.
  • The 15 to 16 migration guide records the change as landing in 16.6.8, and the SSE docs describe the empty data: field.

Test plan

  • The pinned SSE bodies in DeferOverHttpTests, GraphQLOverHttpSpecTests, and DeferredResultFormatterTests expect the new line; they fail without the formatter change and pass with it.
  • ReadAsResultStream_Text_Event_Stream_Complete_With_Empty_Data_Ends_Stream checks that GraphQLHttpClient stops reading at the new complete event.
  • HotChocolate.AspNetCore.Tests, HotChocolate.Transport.Http.Tests, and HotChocolate.Fusion.AspNetCore.Tests pass on net10.0.
  • In headless Chromium, an EventSource against Hot Chocolate re-ran { hello } every 3 s; against the same bytes with the empty data: field it fired complete once and closed.
  • graphql-sse 1.3.2 and 2.6.2 and @urql/core 6.0.3 return the same results for both forms.

Copilot AI lite review requested due to automatic review settings October 1, 2026 09:38
@github-actions github-actions Bot added 📚 documentation This issue is about working on our documentation. 🌶️ hot chocolate labels Oct 1, 2026

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.

Copilot review overview

🟢 Approval recommended

The fix has regression coverage, updated documentation, and no unresolved review issues.

Review effort: Lite
Findings: None

What changed in this PR

Fixes SSE complete events so browser EventSource clients receive them without reconnecting.

Changes:

  • Emit an empty data: field on completion events.
  • Update SSE documentation and migration guidance.
  • Refresh response expectations and add client termination coverage.
File Summary
website/​content/​docs/​hotchocolate/​server/​http-transport.md Documents the completion wire format.
website/​content/​docs/​hotchocolate/​migrating/​migrate-from-15-to-16.md Documents the migration impact.
website/​content/​docs/​fusion/​subscriptions.md Updates the subscription SSE example.
src/​HotChocolate/​AspNetCore/​test/​Transport.Http.Tests/​GraphQLHttpClientTests.cs Verifies empty-data completion ends streams.
src/​HotChocolate/​AspNetCore/​test/​AspNetCore.Tests/​Serialization/​DeferredResultFormatterTests.cs Updates deferred SSE expectations.
src/​HotChocolate/​AspNetCore/​test/​AspNetCore.Tests/​GraphQLOverHttpSpecTests.cs Updates HTTP SSE snapshots.
src/​HotChocolate/​AspNetCore/​test/​AspNetCore.Tests/​DeferOverHttpTests.cs Updates deferred response snapshots.
src/​HotChocolate/​AspNetCore/​src/​Transport.Formatters/​EventStreamResultFormatter.cs Emits data: on completion events.

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

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (1/1)

File Covered Changed Patch %
…/src/Transport.Formatters/EventStreamResultFormatter.cs 1 1 100.0% 🟢

Project coverage: 57.8% (299356/518147 lines)

@glen-84
glen-84 merged commit 51c5d74 into main Oct 1, 2026
159 checks passed
@glen-84
glen-84 deleted the gai/sse-complete-empty-data-field branch October 1, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📚 documentation This issue is about working on our documentation. 🌶️ hot chocolate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants