Skip to content

fix(event_handler): prevent deadlock when async middleware raises before calling next()#8196

Merged
leandrodamascena merged 3 commits intodevelopfrom
fix/8187
May 4, 2026
Merged

fix(event_handler): prevent deadlock when async middleware raises before calling next()#8196
leandrodamascena merged 3 commits intodevelopfrom
fix/8187

Conversation

@leandrodamascena
Copy link
Copy Markdown
Contributor

Issue number: closes #8187

Summary

In this PR I fix a deadlock in AsyncMiddlewareFrame that happens when a sync middleware raises an exception before calling next(). The asyncio.Event was never set, so await middleware_called_next.wait() would hang forever

Changes

Please provide a summary of what's being changed

User experience

Please share what the user experience looks like before and after this change


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@leandrodamascena leandrodamascena requested a review from a team as a code owner May 4, 2026 09:14
@leandrodamascena leandrodamascena requested a review from svozza May 4, 2026 09:14
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 4, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.72%. Comparing base (53678cf) to head (907db32).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8196   +/-   ##
========================================
  Coverage    96.72%   96.72%           
========================================
  Files          286      286           
  Lines        14342    14346    +4     
  Branches      1200     1201    +1     
========================================
+ Hits         13872    13876    +4     
  Misses         341      341           
  Partials       129      129           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 4, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 4, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@leandrodamascena leandrodamascena merged commit f4644f7 into develop May 4, 2026
17 checks passed
@leandrodamascena leandrodamascena deleted the fix/8187 branch May 4, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

event_handlers size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: HttpResolverLocal deadlocks on RequestValidationError under uvicorn (sync middleware that raises before calling next)

2 participants