-
Notifications
You must be signed in to change notification settings - Fork 84
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
BrokenResourceError on metrics endpoint #167
Comments
I've got exactly the same problem. I get this error for a bunch of endpoints but the most problematic one is the health endpoint that's pretty simple: @router.get("/health")
async def health():
val = await database.fetch_val("SELECT 1")
if val == 1:
return "Ok"
raise HTTPException(500, "Can't connect to DB") |
It happens randomly on all endpoints. Maybe your health endpoint is used the most, therefore it seems most problematic for you. |
@mdczaplicki yeah, it happens on all endpoints, but the health endpoint restarts my service when it fails too often, which is a problem. It's also a pretty simple endpoint, so I thought it's worth including for illustrative purposes. |
@mdczaplicki I upgraded FastAPI, prometheus-fastapi-instrumentator and uvicorn to the latest versions, and I haven't seen this error in the last hour 🤞 |
I did as well. Only FAPI was to be updated, though didn't go away. :/ |
@circlingthesun, what other 3rd party packages do you use in your project? Do you still not get the error? I've realized that our pods are also restarted, because health endpoint fails. |
@mdczaplicki I don't use any other middleware (which seems to be the culprit) beside the starlette/fastapi CORS middleware. If you think you can make progress by looking at my dependencies here you go:
|
@mdczaplicki I forgot I'm also using sentry's middleware here are the relavant lines:
|
Hmm, and you're sure that you get rid of I suppose you have |
@mdczaplicki yes, |
Uuu, thanks for the hint. We use |
@mdczaplicki its not completely gone, but since upgrading my dependencies on the 26th, there has been exactly 3 occurrences: |
@mdczaplicki ha ha, yeah, I vaguely recalled that being the case. |
@circlingthesun, hey man. I'm coming back to you - to let you know that the problem is not with this library. It's related to Sentry middleware. You should update to newest Sentry SDK (1.9.0). In 1.8.0 they've introduced new FastAPI integration method. However, don't rush into updating yet, because this will cause new errors to pop up - much more harsh. Better wait until this PR is merged: getsentry/sentry-python#1532 New integration configuration: https://docs.sentry.io/platforms/python/guides/fastapi/#configure You can also downgrade to 1.5.x to get rid of |
@mdczaplicki it's funny that without sentry we wouldn't be aware of the problem but also wouldn't have the problem. Thanks for the heads up 👍 |
They mention here that it's related to MemoryStream middleware, but I'm not sure it's relevant.
fastapi/fastapi#4041
Versions:
PFI: 5.8.2
FastAPI 0.78
Starlette 0.19.1
Any ideas how to fix it?
The text was updated successfully, but these errors were encountered: