reflex-dev / reflex

🕸️ Web apps in pure Python 🐍
https://reflex.dev
Apache License 2.0
19.55k stars 1.11k forks source link

Timeout uploading large data with REFLEX_USE_GRANIAN=1 #4032

Open masenf opened 2 days ago

masenf commented 2 days ago

My app mostly works on 0.6.1a but I did get the following exception printed in the terminal while uploading a 500MB file. It did not seem to cause my app to fail, just the exception was printed:

[ERROR] Application callable raised an exception
Traceback (most recent call last):
  File ".venv/lib/python3.12/site-packages/granian/_futures.py", line 4, in future_watcher
    await inner(watcher.scope, watcher.proto)
  File ".venv/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File ".venv/lib/python3.12/site-packages/starlette/applications.py", line 113, in __call__
    await self.middleware_stack(scope, receive, send)
  File ".venv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File ".venv/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File ".venv/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response
    await self.app(scope, receive, send)
  File ".venv/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 ".venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
    await app(scope, receive, sender)
  File ".venv/lib/python3.12/site-packages/starlette/routing.py", line 715, in __call__
    await self.middleware_stack(scope, receive, send)
  File ".venv/lib/python3.12/site-packages/starlette/routing.py", line 735, in app
    await route.handle(scope, receive, send)
  File ".venv/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File ".venv/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File ".venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
    await app(scope, receive, sender)
  File ".venv/lib/python3.12/site-packages/starlette/routing.py", line 74, in app
    await response(scope, receive, send)
  File ".venv/lib/python3.12/site-packages/starlette/responses.py", line 250, in __call__
    async with anyio.create_task_group() as task_group:
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 740, in __aexit__
    raise exc_val
  File ".venv/lib/python3.12/site-packages/starlette/responses.py", line 257, in __call__
    await wrap(partial(self.listen_for_disconnect, receive))
  File ".venv/lib/python3.12/site-packages/starlette/responses.py", line 253, in wrap
    await func()
  File ".venv/lib/python3.12/site-packages/starlette/responses.py", line 230, in listen_for_disconnect
    message = await receive()
              ^^^^^^^^^^^^^^^
CancelledError: Future cancelled.

Originally posted by @bertbarabas in https://github.com/reflex-dev/reflex/discussions/4023#discussioncomment-10785456

bertbarabas commented 2 days ago

I can confirm this still happens on 0.6.1 and this time I was able to more easily reproduce it with a 1MB file rather than a large file.