Open ruiheng opened 5 days ago
I don't know how to reproduce this issue. However theses errors usually occur on "slow" or complicate pages.
Are you using async/await properly? See https://github.com/zauberzeug/nicegui/wiki/FAQs#why-is-my-long-running-function-blocking-ui-updates
Thanks. I did not know the 'loop.set_debug' method.
After I add these code
def startup():
loop = asyncio.get_running_loop()
loop.set_debug(True)
loop.slow_callback_duration = 0.05
app.on_startup(startup)
I have this new warning in logs:
Executing <Task pending name='....' coro=<run_coro_on_ui_loop.<locals>.wrapped() running at /.../utils.py:994> wait_for=<Future pending cb=[Protocol._on_waiter_completed(), Task.task_wakeup()] created at /home/ruiheng/.cache/pypoetry/virtualenvs/lyceum-NKmSERnC-py3.11/lib/python3.11/site-packages/asyncpg/connection.py:350> created at /home/ruiheng/lyceum/lyceum/page/utils.py:1001> took 0.415 seconds
It seems that something related to asyncpg takes a little longer time to run. I don't know if 0.4 sec is a big issue. Anyway, the KeyError exception still occurs.
I forgot to mention that my browser that I use to test, actually have some performance issues. I can notice poor performance on all web pages.
@ruiheng Calling a function repeatedly that takes 0.4 sec can sum up and cause problems.
Can you, please, try to provide a minimum reproducible example? Or should we close this issue?
Description
This kind of exception as shown in the following logs, pops up from time to time in the logs of my app.
I don't know how to reproduce this issue. However theses errors usually occur on "slow" or complicate pages.
My guess is: after "await js_request" throws TimeoutError, the JavaScriptRequest instance gets deleted from
JavaScriptRequest._instances
dict. Subsequently, when the response of this JavaScriptRequest arrives, a KeyError is raised.Alternatively there might be some requirements for using 'ui.run_javascript' that I am not aware of.