Fix errors handling in GraphQL subscriptions#1371
Merged
tyranron merged 5 commits intographql-rust:masterfrom Mar 14, 2026
Merged
Fix errors handling in GraphQL subscriptions#1371tyranron merged 5 commits intographql-rust:masterfrom
tyranron merged 5 commits intographql-rust:masterfrom
Conversation
Contributor
Author
FCMFix errors handling in GraphQL subscriptions (#1371)
- support panic handling in `juniper_graphql_ws` crate
- fix errors mapping in `#[graphql_subscription]` macro expansion in `juniper_codegen` crate
- fix memory leak caused by incorrect errors handling in GraphQL subscriptions machinery
- refactor `juniper::ValuesStream` to support error batching in `juniper` crate |
tyranron
approved these changes
Mar 14, 2026
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.
Synopsis
juniper_graphql_wsdoesn't allow end-user to handle panics can happen during resolvers/streams execution.Also, current implementation of
#[graphql_subscription]maps errors incorrectly, which causes memory leak and completely omits errors in GraphQL subscriptions:Omitted errors in GraphQL subscriptions
Each subscription resolves items of its stream, expecting the resolving can fail which is never happens because of the GraphQL specification. And because of this, no errors passed to GraphQL subscription leaving them inside the
Executor.Memory leak
juniper::Executoris shared across all the subscription's items (one executor per subscription). And its errors shared across all the types resolution.Executor::errorsin current implementation only collects errors but neverDrops them, which can lead to a memory leak in long-running subscription regularly emitting errors.Solution
juniper_graphql_wscrate.#[graphql_subscription]macro expansion.juniper::ValuesStreamto support error batching.Checklist