You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In trying to set up a small Flask application to work with an external debugger, I noticed that the way exceptions are handled vs. propagated isn't working as documented in the Working with Debuggers section of the documentation.
The documentation specifies that to use an external debugger you have to play with the debug, use_debugger and use_reloader settings. In the following table I show all possible combinations of debug and use_debugger and what the current behavior is (Note that I'm assuming use_reloader is always set to False for this discussion, as this setting is not part of the problem):
The appropriate configuration for using an external debugger is the one shown in the 3rd row of the above table, but note that with this configuration, exceptions are not propagated all the way up and never reach an external debugger. With this configuration Flask does the right thing and reraises the exception, but the Werkzeug WSGI server then catches it and handles it by logging the stack trace and moving on, because it was not told otherwise.
For this set up to work as documented, Werkzeug's server should have passthrough_errors set to True. If I add this setting to app.run() then exceptions are allowed to reach an external debugger.
My impression is that the value of the PROPAGATE_EXCEPTIONS configuration item should be synchronized with Werkzeug's passthrough_errors, so that Flask and Werkzeug consistently handle or reraise exceptions.
I'm happy to submit a pull request with the fix (which is quite simple), if you accept this as a valid issue. Please let me know what you think.
The text was updated successfully, but these errors were encountered:
In trying to set up a small Flask application to work with an external debugger, I noticed that the way exceptions are handled vs. propagated isn't working as documented in the Working with Debuggers section of the documentation.
The documentation specifies that to use an external debugger you have to play with the
debug
,use_debugger
anduse_reloader
settings. In the following table I show all possible combinations ofdebug
anduse_debugger
and what the current behavior is (Note that I'm assuminguse_reloader
is always set toFalse
for this discussion, as this setting is not part of the problem):The appropriate configuration for using an external debugger is the one shown in the 3rd row of the above table, but note that with this configuration, exceptions are not propagated all the way up and never reach an external debugger. With this configuration Flask does the right thing and reraises the exception, but the Werkzeug WSGI server then catches it and handles it by logging the stack trace and moving on, because it was not told otherwise.
For this set up to work as documented, Werkzeug's server should have
passthrough_errors
set toTrue
. If I add this setting toapp.run()
then exceptions are allowed to reach an external debugger.My impression is that the value of the
PROPAGATE_EXCEPTIONS
configuration item should be synchronized with Werkzeug'spassthrough_errors
, so that Flask and Werkzeug consistently handle or reraise exceptions.I'm happy to submit a pull request with the fix (which is quite simple), if you accept this as a valid issue. Please let me know what you think.
The text was updated successfully, but these errors were encountered: