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

fix: Wrap asgi application to ignore lifetime requests #21802

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

frankh
Copy link
Contributor

@frankh frankh commented Apr 24, 2024

Problem

ASGI servers send "lifetime" requests to django at startup and shutdown.

The ASGI spec allows these to fail, in which case the server ignores them, however the way django fails them sends an exception to sentry which we don't want.

Overwrite the handler to return a 501 error without throwing an exception

Changes

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

How did you test this code?

@frankh frankh requested a review from Twixes April 24, 2024 11:55
Copy link
Contributor

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scary change! I guess dev will pick up if this is an issue?

@frankh
Copy link
Contributor Author

frankh commented Apr 25, 2024

yep and i also got it running locally with no issues. I might canary it anyway just in case

@frankh frankh added the canary label Apr 25, 2024
@frankh frankh force-pushed the frank/ignore-lifetime-requests branch from 20bc9a0 to 71284f3 Compare April 25, 2024 14:34
ASGI servers send "lifetime" requests to django at startup and shutdown.

The ASGI spec allows these to fail, in which case the server ignores them, however
the way django fails them sends an exception to sentry which we don't want.

Overwrite the handler to return a 501 error without throwing an exception
@frankh frankh force-pushed the frank/ignore-lifetime-requests branch from 71284f3 to 12b49e3 Compare April 25, 2024 14:36
@frankh frankh merged commit d2ed2ea into master Apr 25, 2024
96 checks passed
@frankh frankh deleted the frank/ignore-lifetime-requests branch April 25, 2024 15:05
frankh added a commit that referenced this pull request Apr 25, 2024
frankh added a commit that referenced this pull request Apr 25, 2024
Revert "fix: Wrap asgi application to ignore lifetime requests (#21802)"

This reverts commit d2ed2ea.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants