https://supertokens.com/ logo
python issue
t

The Lower Depths

04/24/2023, 10:51 AM
Hello, Thank you for your product, it’s amazing how simple and comfortable it is to set up and use. Your work is breathtaking 🙂 But there’s one issue I ran into. Can you help? I’ve set up supertokens-python on FastAPI(0.95.1), and now I keep getting exceptions:
h11._util.LocalProtocolError: Can't send data when our state is ERROR
It seems that the root cause for it is inheritance from Starlette's BaseHTTPMiddleware https://github.com/encode/uvicorn/issues/111 https://github.com/encode/starlette/issues/1678 Can you help me in rewriting your middleware so it doesn’t use BaseHTTPMiddleware? Specifically, I have no idea what to do with
python
if result is None:
    response = await call_next(request)
r

rp

04/24/2023, 12:13 PM
hey @The Lower Depths
So the default middleware is not working for you as is? Are you doing something custom somewhere?
t

The Lower Depths

04/24/2023, 12:21 PM
Actually yes, I'm using third party email password recipe, and overridden it a bit, but it doesn't look like it is the issue. I started to have this exception after installing supertokens and googling says this error is Starlette's fault. Now I'm wondering can I write your middleware without problematic element as pure ASGI middleware
r

rp

04/24/2023, 12:29 PM
> I started to have this exception after installing supertokens So this is some issue caused by our SDK then?
I think our boilerplate app using
npx create-supertokens-app@latest
with FastAPI works. Have you tried that?
t

The Lower Depths

04/24/2023, 12:33 PM
Oh, I'm sorry, haven't mentioned, it occurs only in unknown circumstances, I have it only in logs of my app. Probably it happens when app is under high pressure
r

rp

04/24/2023, 12:33 PM
ahh i see
t

The Lower Depths

04/24/2023, 12:33 PM
Normally everything works fine
r

rp

04/24/2023, 12:33 PM
is there a way to reproduce it? Maybe we can fix it..
t

The Lower Depths

04/24/2023, 12:34 PM
I have no idea how my users do this. It's their own black magic
I have a traceback though
r

rp

04/24/2023, 12:34 PM
that would be helpful
> Specifically, I have no idea what to do with > if result is None: > response = await call_next(request) This means that if our middleware didn't handle the request, forward the request to your apis / middleware.
r

rp

04/24/2023, 12:38 PM
maybe open an issue about this on our github in the python repo. So that it doesn't get lost
t

The Lower Depths

04/24/2023, 12:41 PM
Ok, I'll do it, though its issues section looks a bit deserted
Anyway, thank you for your help 🙂
r

rp

04/24/2023, 12:43 PM
if you can shed some light on how we can reproduce it, that would go a long way to help us fixing this.