Skip to content

Conversation

@sentrivana
Copy link
Contributor

@sentrivana sentrivana commented Aug 1, 2023

For capturing GraphQL responses we're read()ing the HTTPResponse returned by http.client.HTTPConnection.getresponse, which exhausts the payload and it can't be read again by client applications. The original workaround for this was saving the payload in a BytesIO and aliasing HTTPResponse.read to the BytesIO's read. This works when using http.client directly, but stops working with urllib3, which tries to determine whether there's anything left to read by checking if the response is closed, which in turn checks the internal fp file object. By the time we've read() the response, fp is None, and the response appears closed. This PR patches fp to point to the BytesIO saved response.

Fixes #2285

@sentrivana sentrivana marked this pull request as ready for review August 1, 2023 10:44
@sentrivana sentrivana requested a review from sl0thentr0py August 1, 2023 10:46
@sentrivana sentrivana merged commit e918504 into master Aug 1, 2023
@sentrivana sentrivana deleted the ivana/fix-graphql-swallowing-response branch August 1, 2023 11:02
sentrivana added a commit that referenced this pull request Aug 1, 2023
sentrivana added a commit that referenced this pull request Aug 1, 2023
* Revert "Fix GraphQL integration swallowing responses (#2286)"

This reverts commit e918504.

* Revert "Capture GraphQL client errors (#2243)"

This reverts commit 5199d54.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sentry sdk causes requests to return an empty response when using graphql query

3 participants