Overview
Flask 3.1.2, released on August 19, 2025, fixes an issue with stream_with_context in async mode.
Main Features
Async stream_with_context fix
The stream_with_context decorator now works correctly with async generators, enabling response streaming with access to the request context.
python
from flask import Flask, stream_with_context, Response
app = Flask(__name__)
@app.route('/stream')
async def streamed_response():
@stream_with_context
async def generate():
for i in range(10):
yield f'data: {i}\n\n'
return Response(generate(), content_type='text/event-stream')
