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

werkzeug times out when exception is raised #1536

Closed
RazerM opened this issue May 7, 2019 · 2 comments
Closed

werkzeug times out when exception is raised #1536

RazerM opened this issue May 7, 2019 · 2 comments

Comments

@RazerM
Copy link

@RazerM RazerM commented May 7, 2019

I found this within a large Flask application but I managed to reproduce it.

SQLAlchemy's exceptions contain an .orig attribute with the original DBAPI exception. I only raised it to see it in the werkzeug debugger, and found that the debugger page never loads.

from werkzeug.wrappers import Request, Response
from sqlalchemy import create_engine, text
from sqlalchemy.exc import DatabaseError

engine = create_engine('sqlite://')


@Request.application
def application(request):
    try:
        engine.execute(text('SELECT undefined_function()'))
    except DatabaseError as exc:
        # if we just re-raise, it works fine
        # raise

        # exc.orig is definitely an exception
        assert isinstance(exc.orig, Exception)

        # werkzeug doesn't return a response when this is raised
        raise exc.orig
    return Response('This is unreachable')


if __name__ == '__main__':
    from werkzeug.serving import run_simple
    run_simple('localhost', 4000, application, use_debugger=True)

The same happens for a PostgreSQL (psycopg2) connection.

@RazerM
Copy link
Author

@RazerM RazerM commented May 7, 2019

Using git bisect I found 3245e58

@davidism
Copy link
Member

@davidism davidism commented May 12, 2019

Thanks for tracking this down. This is the first time I've seen an exception context cycle. I added cycle detection to the formatter.

@davidism davidism closed this May 12, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants