Repository navigation
Fix EventSource never receiving the SSE complete event - #10462
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.
Contributor
Patch coverage100.0% of changed lines covered (1/1)
Project coverage: 57.8% (299356/518147 lines) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
text/event-streamresponse ended withevent: completeand nodata:field. The browserEventSourceAPI does not dispatch an event without data, so anEventSourceclient never sawcomplete: 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.completeevent now carries an emptydata: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 inGraphQLHttpClientand the Fusion subgraph client, accept both forms, so a gateway and subgraph on different versions are unaffected.data:field.Test plan
DeferOverHttpTests,GraphQLOverHttpSpecTests, andDeferredResultFormatterTestsexpect the new line; they fail without the formatter change and pass with it.ReadAsResultStream_Text_Event_Stream_Complete_With_Empty_Data_Ends_Streamchecks thatGraphQLHttpClientstops reading at the newcompleteevent.HotChocolate.AspNetCore.Tests,HotChocolate.Transport.Http.Tests, andHotChocolate.Fusion.AspNetCore.Testspass on net10.0.EventSourceagainst Hot Chocolate re-ran{ hello }every 3 s; against the same bytes with the emptydata:field it firedcompleteonce and closed.@urql/core6.0.3 return the same results for both forms.