-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[BUG] debug=True
and @app.server.before_request
→ AttributeError: '_AppCtxGlobals' object has no attribute 'timing_information'
#1475
Comments
Ah interesting - so when you do a redirect in your own Whichever it is, I think it'd be fine to just bail out of our |
Running into this issue. Any recommendations for workarounds? |
From my understanding, the cause is that the custom Lines 1463 to 1466 in ab212a3
What I did as a workaround was to create a new import flask
import dash
import dash_html_components as html
import time
app = dash.Dash()
app.server.config["DEBUG"] = True
app.layout = html.Div("Hello world")
if app.server.config["DEBUG"]:
@app.server.before_request
def _before_request():
flask.g.timing_information = {
"__dash_server": {"dur": time.time(), "desc": None}
}
@app.server.before_request
def some_function():
if flask.request.args.get("redirect_me") == "yes":
return flask.redirect(flask.request.base_url)
if __name__ == "__main__":
app.run_server(debug=app.server.config.get("DEBUG", False)) |
Thanks @baurt |
debug=True
and @app.server.before_request
→ AttributeError: '_AppCtxGlobals' object has no attribute 'timing_information'
Issue is resolved in PR #1640 |
@remibaar 🎉 👏 - thanks |
Describe your context
Please provide us your environment so we can easily reproduce the issue.
pip list | grep dash
belowDescribe the bug
With
debug=True
:What happens
In our use case we use the Dash provided Flask server (
app.server
) to set up abefore_request
. On certain conditions (more specifically, certainGET
parameters in the URL) we do aflask
redirect.In
dash<1.16
the minimal example below works, however indash>=1.16
it fails with the above traceback.A minimal example
Go to http://127.0.0.1:8050/?redirect_me=yes
Expected behaviour
Not entirely sure what is best behavior. One possible option: If server timing is not possible to calculate,
return response
without adding header"Server-Timing"
and displaying it in the frontend (for the given request)?dash/dash/dash.py
Lines 1468 to 1483 in ab212a3
The text was updated successfully, but these errors were encountered: