Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore BrokenResourceError in BaseHTTPMiddleware #1318

Closed
wants to merge 3 commits into from

Conversation

brakhane
Copy link

@brakhane brakhane commented Oct 20, 2021

ASGI specifies that send is a no-op when the connection is closed.

HTTPMiddleware uses anyio streams which will raise
an exception when the connection is closed prematurely.

So we need to ignore the exception in our send function.

Fixes #1284

@brakhane brakhane force-pushed the fix-broken-resource-error branch 4 times, most recently from 41672b2 to b1b384e Compare October 21, 2021 11:57
ASGI specifies that send is a no-op when the connection is closed.

HTTPMiddleware uses anyio streams which will raise
an exception when the connection is closed prematurely.

So we need to ignore the exception in our send function.

Fixes encode#1284
@brakhane
Copy link
Author

The failing test seems like a random segmentation fault and I don't think my changes are responsible.

@havardthom havardthom mentioned this pull request Nov 1, 2021
2 tasks
@Kludex
Copy link
Sponsor Member

Kludex commented Nov 15, 2021

Hey @brakhane , thanks for PR! 😎

I see this was already solved on #1262, so I'm closing this PR.

@Kludex Kludex closed this Nov 15, 2021
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.

anyio.BrokenResourceError when using BaseHTTPMiddleware
2 participants