Skip to content
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

When using an external debugger, exceptions are not properly propagated #1674

Closed
miguelgrinberg opened this issue Jan 1, 2016 · 0 comments · Fixed by #1679
Closed

When using an external debugger, exceptions are not properly propagated #1674

miguelgrinberg opened this issue Jan 1, 2016 · 0 comments · Fixed by #1679

Comments

@miguelgrinberg
Copy link
Contributor

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):

| debug | use_debugger | Who catches exceptions | Correct behavior?               |
+-------+--------------+------------------------+---------------------------------+
| True  | True         | Werkzeug's debugger    | Yes                             |
| False | True         | Flask, returns 500     | Yes (I think?)                  |
| True  | False        | Werkzeug's WSGI server | No, exceptions should propagate |
| False | False        | Flask, returns 500     | Yes                             |

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.

binux added a commit to binux/pyspider that referenced this issue Jun 5, 2016
I just need a simple_run, not expect this!
pallets/flask#1674
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant