#277 — [Bug]: RuntimeError: Cannot call “send” once a close message has been sent.
Repo: Twill-AI/facade State: closed | Status: done Assignee: Unassigned
Created: 2025-01-22 · Updated: 2025-03-24
Description
Steps to reproduce
- Create an integration in Facade in staging (might happen also in production).
- Close the browser tab/window immediately.
- Error is logged and call to Facade’s bdstate router fails from BusinessData.
Expected behavior
Invoking POST /tenants/{tenant_id}/bdintegrations/{bd_integration_id} shouldn’t be affected by errors when notifying users.
Actual behavior
It seems like, if the user’s websocket is disconnected, the following error is raised and the bdstate endpoint returns a failed response:
Error log
2025-01-17 04:00:47.771|ERROR|master|fastapi_utils:304|FINISH POST http://ca-prod-twill-eastus-facade/api/v1/master/bdstate/tenants/VMGCORP7j0/bdintegrations/1 took 0.086: duration=85ms exception in middlewares:
Traceback (most recent call last):
File "/app/app/core/fastapi_utils.py", line 282, in __call__
await self.app(scope, receive_wrapper, send_wrapper)
File "/usr/local/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 715, in __call__
## Notes
_Add implementation notes, blockers, and context here_
## Related
_Add wikilinks to related people, meetings, or other tickets_