Skip to content

Conversation

basepi
Copy link
Contributor

@basepi basepi commented Feb 5, 2021

What does this pull request do?

Because Starlette does not propagate the cached request._body properly, we've always had to use a hack in order to make sure we don't hang requests by streaming the body before the request does.

This PR ensures that for any capture_body setting that's not off, we perform this hack in the pre-request stage so that everyone will have easy access to the body down the line.

Before this fix, if capture_body was set to error, and an error was thrown after the body was already streamed, we would hang while trying to capture the body. I consider this a bug in Starlette but this should let us work around it.

Related issues

Fixes #1032

@ghost
Copy link

ghost commented Feb 5, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #1038 updated

    • Start Time: 2021-02-05T00:04:05.479+0000
  • Duration: 25 min 33 sec

  • Commit: b7a67d7

Test stats 🧪

Test Results
Failed 0
Passed 8415
Skipped 5888
Total 14303

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 8415
Skipped 5888
Total 14303

@basepi basepi merged commit 63fbeb9 into elastic:master Feb 5, 2021
beniwohli pushed a commit to beniwohli/apm-agent-python that referenced this pull request Sep 14, 2021
* Fix for hang on capture_body: error in starlette

* Add CHANGELOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

capture_body makes requests hangs / validation error
2 participants