question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ClientDisconnect thrown from Starlette for FastApi Integration

See original GitHub issue

How do you use Sentry?

Sentry Saas (sentry.io)

Version

1.9.0

Steps to Reproduce

  1. Install the lib v1.9.0;
  2. Configure the sentry initialization as described in the release documentation:
from fastapi import FastAPI
from sentry_sdk.integrations.starlette import StarletteIntegration
from sentry_sdk.integrations.fastapi import FastApiIntegration

sentry_sdk.init(
  dsn="...",
  integrations=[
        StarletteIntegration(), 
        FastApiIntegration()
  ],
)
app = FastAPI()

Originally my application (which is running on Rancher k8s, behind an nginx ingress controller) has a SentryAsgiMiddleware instrumented and function normally. However, when I switch to use the new beta FastApiIntegration(), my application can start but would throw errors for all requests.

Strangely though, this setup would work locally when I am using localhost.

Expected Result

My FastAPI server instance should function normally. Messages and errors should be captured and sent to my Sentry SAAS instance.

Actual Result

The server hangs up on request to the server. An ClientDisconnect Error is thrown and received by Sentry.

image

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
biel-michaelcommented, Aug 5, 2022

@antonpirker We have tried to use #1532. It seems like the head of that branch has indeed fixed the issue! Here are some screenshots for the result:

fastapi-sentry-branch k8s-sentry sentry-branch

We have also double checked that the released v1.9.0 version of the library is not working, as we have previously depicted when we opened the issue.

3reactions
biel-michaelcommented, Aug 12, 2022

After a few trials, we settled with v1.9.3 and it is running live on production. We are still in the progress of instrumenting our frontend repository but everything is looking good on the Python side right now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

FastAPI and Starlette Sentry Integrations Have Arrived
FastAPI is known for building REST APIs, middleware services, and simple integration for adding authentications and more.
Read more >
RuntimeError: No response returned in FastAPI when refresh ...
After checking the code I found that starlette BaseHTTPMiddleware.__call__ method is throwing this error when the client disconnects the ...
Read more >
tiangolo/fastapi - Gitter
It's handled in a middleware. E.g. from fastapi import FastAPI, Depends from starlette.responses import JSONResponse app = FastAPI() class ...
Read more >
Third Party Packages - Starlette
Check out how to integrate with Starlette. ... A simple tool for integrating Starlette and WTForms. ... FastAPI style routing for Starlette.
Read more >
Developing a Single Page App with FastAPI and Vue.js
Along with the apps themselves, you'll add authentication and integrate them together. It's assumed that you have experience with FastAPI, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found