Chainlit / chainlit

Build Conversational AI in minutes ⚡️
https://docs.chainlit.io
Apache License 2.0
6.78k stars 882 forks source link

Element loading error #628

Closed jdb78 closed 8 months ago

jdb78 commented 8 months ago

I deployed Chainlit on an Azure Web App. Generally, it seems to work but when I want to load text elements in a side panel there are issues and I get "An error occured".

In the Chrome console, I am getting Error 400 “Invalid HTTP request received.” This relates to a request https://****.azurewebsites.net/project/file/****?session_id=****&token

In the logs of the web app:

2024-01-04T09:23:38.924101521Z fail: Middleware[0]
2024-01-04T09:23:38.924139381Z Failed to forward request to http://****:8000. Encountered a System.IO.IOException exception after 2.334ms with message: Unable to read data from the transport connection: Connection reset by peer.. Check application logs to verify the application is properly handling HTTP traffic.
2024-01-04T09:23:38.925436954Z fail: Microsoft.AspNetCore.Server.Kestrel[13]
2024-01-04T09:23:38.925457703Z Connection id "****", Request id "****:00000002": An unhandled exception was thrown by the application.
2024-01-04T09:23:38.925761363Z System.InvalidOperationException: StatusCode cannot be set because the response has already started.
2024-01-04T09:23:38.926643640Z at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ThrowResponseAlreadyStartedException(String value)
2024-01-04T09:23:38.926649602Z at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.set_StatusCode(Int32 value)
2024-01-04T09:23:38.926654020Z at Microsoft.Azure.AppService.Middleware.Forwarding.RequestForwarder.OnRequest(HttpContext context) in /__w/1/s/src/EasyAuth/Middleware.Forwarding/RequestForwarder.cs:line 92
2024-01-04T09:23:38.926658719Z at Microsoft.Azure.AppService.Middleware.NetCore.AppServiceMiddleware.InvokeAsync(HttpContext context) in /__w/1/s/src/EasyAuth/Microsoft.Azure.AppService.Middleware.NetCore/AppServiceMiddleware.cs:line 140
2024-01-04T09:23:38.927026228Z at Microsoft.Azure.AppService.MiddlewareShim.AutoHealing.AutoHealingMiddleware.Invoke(HttpContext context) in /__w/1/s/src/EasyAuth/Middleware.Host/AutoHealing/AutoHealingMiddleware.cs:line 59
2024-01-04T09:23:38.927233756Z at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

The strange thing is that in some rare instances it works as expected. Any idea what the issue could be?

willydouhard commented 8 months ago

This is interesting. Would love to hop on a quick call to identify the root cause. Can you DM me on discord?

jdb78 commented 8 months ago

I'll get back to you tomorrow. In the meantime: Maybe this is the issue: https://roopa-vrb.medium.com/400-bad-request-on-azure-app-service-a-story-3ef244ec3cce. The token is indeed really long, so maybe better to put it into the header?

willydouhard commented 8 months ago

Opened this PR to check if this is the issue. Are you able to build from sources? If not I can build the wheel myself.

jdb78 commented 8 months ago

Think this was due to my botched implementation of a custom data layer