Repository navigation
Conversation
Apollo 3 and 4 peeked at the full response body to detect GraphQL errors before returning the response. For multipart (@defer/@stream) and server-sent event responses, that read waits for the end of the stream, breaking incremental delivery. Skip body inspection for multipart/mixed and text/event-stream responses, and check failedRequestTargets before reading the body. This matches the Apollo 5 integration. Spans and breadcrumbs are still recorded. Fixes #5987 (cherry picked from commit dceacfe)
📲 Install BuildsAndroid
|
5 of 9 tasks
Collaborator
Author
|
@sentry review |
Collaborator
Author
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e2233df. Configure here.
This branch has not been deployed
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.
📜 Description
The Apollo 3 and 4 integrations no longer inspect the response body of streaming responses (
multipart/mixed,text/event-stream) for GraphQL errors, and they now checkfailedRequestTargetsbefore reading the body at all.Previously, failed-request detection peeked at the entire response body (
response.body?.peek()?.readUtf8()) before the interceptor returned the response. For multipart responses used by@defer/@stream(and multipart subscriptions), that read waits for the end of the stream, so incremental delivery stalls until the whole response has arrived, or indefinitely for unbounded streams.This ports the behavior the Apollo 5 integration already has since #6074 (
SentryApollo5HttpInterceptor.isStreamingResponse). Spans and breadcrumbs are still recorded for streaming responses; they are written infinish(), which does not read the body.Per the decision on the issue, there is no option to re-enable inspection for multipart responses. GraphQL errors delivered inside multipart parts are therefore not reported as failed requests.
Apollo 3 is not listed in the issue, but Apollo Kotlin 3.x also supports
@deferover multipart and had the same code path, so it is included.💡 Motivation and Context
Adding Sentry to an Apollo client breaks
@defer/@stream.💚 How did you test it?
Ported the Apollo 5 tests to Apollo 3 and 4. Each test calls the interceptor directly with a response body that records whether it was read:
multipart/mixedandtext/event-stream(case- and parameter-insensitive)application/jsonand for responses without a content typeThe three "not read" tests failed before the fix. The fixture uses a non-empty
errorsarray../gradlew :sentry-apollo-3:check :sentry-apollo-4:check :sentry-apollo-5:checkAdded
google-truthas a test dependency tosentry-apollo-3andsentry-apollo-4.Targets
mainso 8.x users get the fix; it reaches9.x.xvia the regular main → 9.x.x sync.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps