pallets-eco / pallets-eco/flask-debugtoolbar

incompatible with flask 2 and async

Open
#158 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
978
Forks
151
PR merge metrics
No merged PRs in 30d

Description

It seems that flask-debugtoolbar is incompatible with flask 2 async endpoints.

Repro:

Run this flask project (app.py) and hit /data to trigger an async call - which works.

Then uncomment the line enabling the DebugToolbarExtension and we get an exception.

import asyncio
from flask import Flask
from flask import render_template
from icecream import ic
from flask_debugtoolbar import DebugToolbarExtension

app = Flask(__name__)

app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
app.config['JSON_SORT_KEYS'] = False
app.secret_key = 'super secret key'

# flask debug toolbar - https://flask-debugtoolbar.readthedocs.io/en/latest/index.html#configuration
app.debug = True
app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False
app.config['DEBUG_TB_TEMPLATE_EDITOR_ENABLED'] = True
# toolbar = DebugToolbarExtension(app)  # <<<< UNCOMMENT THIS AND WATCH IT CRASH

@app.route('/')
def root():
    return "hi"


async def async_get_data():
    ic('in async function')
    await asyncio.sleep(2)
    ic('out of async function')
    return 'Done!'


@app.route("/data")
async def get_data():
    data = await async_get_data()
    return data

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the app.py reproduction: run the Flask project, enable DebugToolbarExtension, and request /data to capture the exception. Trace the toolbar path involved in async endpoints; done when the example works with the toolbar enabled and the regression is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python
Domain
backend, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.