[Root cause found] Async function problem on Docker #4457
Labels
bug
Something isn't working
need repro example
Need an example that can be copy/pasted to reproduce the issue immediately
Describe the bug
When running the app in a Docker container, the app keeps have async problem issue. The problem comes from Reflex's internal HTTPX client wrapper is trying to access a _state attribute that doesn't exist.
On the front-end side, the app just stops running the async function and display a message prompting to "Contact the website administrator". The app still works for the rest, only the change supposedly done by the async function do no have effect.
A typical error message print this way through logging:
ERROR - asyncio - Task exception was never retrieved future: <Task finished name='Task-2506' coro=<AsyncClient.aclose() done, defined at /app/.venv/lib/python3.11/site-packages/httpx/_client.py:1980> exception=AttributeError("'AsyncHttpxClientWrapper' object has no attribute '_state'")> Traceback (most recent call last): File "/app/.venv/lib/python3.11/site-packages/httpx/_client.py", line 1984, in aclose if self._state != ClientState.CLOSED: ^^^^^^^^^^^ AttributeError: 'AsyncHttpxClientWrapper' object has no attribute '_state'
[EDIT] After a week of research we found out that the problem comes from the new decorator rx.event(background=True). When it has an "async with self:" it causes the app to execution in a Docker container. Without this, it works all good.
To Reproduce
Run an app from a Docker Container. The issue occurred both locally (running the container with Docker Windows and in remotely by using DockerHub deployed on Linode.
System: Windows 10
OS: WSL, Ubuntu
Expected behavior
The async function should be redirecting to another page of the app. But it just does not run the function.
Screenshots
Not applicable
Specifics (please complete the following information):
Additional context
None
The text was updated successfully, but these errors were encountered: