Skip to content

Feature request: add AsyncMiddlewareFrame for async resolver support #8134

@leandrodamascena

Description

@leandrodamascena

Use case

The current MiddlewareFrame is synchronous - it builds a recursive call chain where each middleware calls the next synchronously. To support async handlers, we need an async counterpart that can await async middlewares while still supporting existing sync middlewares transparently.

Solution/User Experience

  • Add AsyncMiddlewareFrame class in aws_lambda_powertools/event_handler/api_gateway.py (next to MiddlewareFrame)
  • Auto-detects sync vs async middleware using inspect.iscoroutinefunction()
  • For async middleware: awaits it directly
  • For sync middleware: uses the threading utilities extracted in PR 1
  • Unit tests for the new class
  • Nothing calls it yet in production code - internal building block only

Alternative solutions

Acknowledgment

Metadata

Metadata

Projects

Status

Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions