Skip to content

Conversation

JohnnyDeuss
Copy link
Contributor

@JohnnyDeuss JohnnyDeuss commented Jan 16, 2023

When the StarletteIntegration is used in a FastAPI app, as instructed in the docs, the AuthenticationMiddleware and ExceptionMiddleware get patched every time add_middleware or add_exception_handler is called, since these methods call build_middleware_stack, where patched Middleware instances are repatched without checking if they were already patched.

If these functions are called enough times, Python registers this as infinite recursion (as we've discovered).

The changes look broad, but amount to the addition of two if not_yet_patched checks and indentation.

@antonpirker
Copy link
Member

Hey @JohnnyDeuss
Can you fix the "Lint Sources" issues shown above?
You probably just need to reformat the code locally by calling black tests sentry_sdk in the root directory.

@antonpirker antonpirker merged commit 0714d9f into getsentry:master Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants