Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to update elements on Posit Connect #3584

Open
aca-trevor-winn opened this issue Aug 23, 2024 · 15 comments
Open

Unable to update elements on Posit Connect #3584

aca-trevor-winn opened this issue Aug 23, 2024 · 15 comments
Labels
help wanted Extra attention is needed

Comments

@aca-trevor-winn
Copy link

aca-trevor-winn commented Aug 23, 2024

Description

Requirements.txt

nicegui==1.4.36
openpyxl==3.0.10
pyodbc==5.1.0
rsconnect-python==1.20.0
sqlparse==0.4.4
ipython==8.14.0
thefuzz==0.22.1

Minimal example:

from fastapi import FastAPI, Request
from fastapi.responses import FileResponse, RedirectResponse
from nicegui import app, ui, run, Client

fast_app = FastAPI()

@ui.page('/', title="Account Pull", response_timeout=240)
def page_layout():
    l = ui.label("Hello World")
    def test():
        l.text = "Pineapple"
        l.update()
    ui.button("Test", on_click=test)

ui.run_with(fast_app, storage_secret="secret")

image

In my local version the word changes to pineapple as expected, but on posit the word does not change. It seems the .update function isn't working possibly?
I am unsure as there are no errors thrown and nothing in the logs.
I have spent about 3 hours googling and trying to debug this, I am hoping I am missing something obvious.

@aca-trevor-winn
Copy link
Author

Something I forgot to note. Nicegui 1.4.8 and fastapi 1.0.8 does not have this problem.

@rodja
Copy link
Member

rodja commented Aug 24, 2024

Strange. Do you see the notification popup when using

@ui.page('/')
def index():
    ui.button('click me', on_click=lambda: ui.notify('It works!'))

Do you see any interesting in the javascript console?

@falkoschindler
Copy link
Contributor

@aca-trevor-winn What do you mean with FastAPI 1.0.8? Its latest version is 0.112.1.

@aca-trevor-winn
Copy link
Author

aca-trevor-winn commented Aug 26, 2024

Strange. Do you see the notification popup when using

@ui.page('/')
def index():
    ui.button('click me', on_click=lambda: ui.notify('It works!'))

Do you see any interesting in the javascript console?

No, I just tested and the notify did not work and nothing in the logs except pkg_resource being deprecated
image

2024/08/26 8:46:20 AM: Linux distribution: Red Hat Enterprise Linux release 8.8 (Ootpa)
2024/08/26 8:46:20 AM: Running as user: uid=994(rstudio-connect) gid=990(rstudio-connect) groups=990(rstudio-connect) context=system_u:system_r:unconfined_service_t:s0
2024/08/26 8:46:20 AM: Connect version: 2024.08.0
2024/08/26 8:46:20 AM: LANG: en_US.UTF-8
2024/08/26 8:46:20 AM: Working directory: /opt/rstudio-connect/mnt/app
2024/08/26 8:46:20 AM: Bootstrapping environment using Python 3.11.9 (main, May  7 2024, 12:38:02) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] at /opt/python/3.11.9/bin/python3.11
2024/08/26 8:46:20 AM: Running content with the Python virtual environment /opt/rstudio-connect/mnt/app/python/env (/opt/rstudio-connect/mnt/python-environments/pip/3.11.9/Li-v-HTWaKgIcTOtlRZsNA)
2024/08/26 8:46:21 AM: /opt/rstudio-connect/python/connect_fastapi_runtime.py:9: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
2024/08/26 8:46:21 AM:   from pkg_resources import parse_version
2024/08/26 8:46:21 AM: Running content using Python "3.11.9 (main, May  7 2024, 12:38:02) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)]" at "/opt/rstudio-connect/mnt/app/python/env/bin/python"
2024/08/26 8:46:21 AM: Loading code from "app"
2024/08/26 8:46:21 AM: App type is "App"
2024/08/26 8:46:21 AM: Starting server...

@aca-trevor-winn What do you mean with FastAPI 1.0.8? Its latest version is 0.112.1.

When upgrading nicegui past 1.4.8 it requires fastapi >1.0.8. I was just stating the Fastapi version that was working with the nicegui version I was using.
Notify and updating elements works on Posit with Nicegui 1.4.8 but breaks on Nicegui >= 1.4.9

So opening up the consoles network panel I do see a websocket request being sent. I have also checked and onclick events are working. The UI is just not updating for some reason.

I apologize for the late response, I posted this right before heading out for the weekend.

@aca-trevor-winn
Copy link
Author

aca-trevor-winn commented Aug 26, 2024

Packages in the environment:

aiofiles==24.1.0
aiohappyeyeballs==2.4.0
aiohttp==3.10.5
aiosignal==1.3.1
annotated-types==0.7.0
anyio==4.4.0
asttokens==2.4.1
attrs==24.2.0
backcall==0.2.0
bidict==0.23.1
certifi==2024.7.4
charset-normalizer==3.3.2
click==8.1.7
decorator==5.1.1
docutils==0.21.2
et-xmlfile==1.1.0
executing==2.0.1
fastapi==0.109.2
frozenlist==1.4.1
h11==0.14.0
httpcore==1.0.5
httptools==0.6.1
httpx==0.27.0
idna==3.8
ifaddr==0.2.0
ipython==8.14.0
itsdangerous==2.2.0
jedi==0.19.1
Jinja2==3.1.4
markdown2==2.5.0
MarkupSafe==2.1.5
matplotlib-inline==0.1.7
multidict==6.0.5
nicegui==1.4.36
openpyxl==3.0.10
orjson==3.10.7
parso==0.8.4
pexpect==4.9.0
pickleshare==0.7.5
prompt_toolkit==3.0.47
pscript==0.7.7
ptyprocess==0.7.0
pure_eval==0.2.3
pydantic==2.8.2
pydantic_core==2.20.1
Pygments==2.18.0
pyodbc==5.1.0
python-dotenv==1.0.1
python-engineio==4.9.1
python-multipart==0.0.9
python-socketio==5.11.3
PyYAML==6.0.2
rapidfuzz==3.9.6
requests==2.32.3
simple-websocket==1.0.0
six==1.16.0
sniffio==1.3.1
sqlparse==0.4.4
stack-data==0.6.3
starlette==0.36.3
thefuzz==0.22.1
traitlets==5.14.3
typing_extensions==4.12.2
urllib3==2.2.2
uvicorn==0.30.6
uvloop==0.20.0
vbuild==0.8.2
watchfiles==0.23.0
wcwidth==0.2.13
websockets==13.0
wsproto==1.2.0
yarl==1.9.4

These are the packages in the Posit Environment

@falkoschindler
Copy link
Contributor

Around version 1.4.8 we had some problems with an incompatibility with FastAPI 0.109.x, see #2354. Could you try upgrading to a newer NiceGUI version, e.g. 1.4.37? Or do you rely on FastAPI 0.108.x?

@aca-trevor-winn
Copy link
Author

aca-trevor-winn commented Aug 29, 2024

What I meant was NiceGUI 1.4.8 DOES work but any version greater than that doesn't.

Here is the code I am using to test:

from fastapi import FastAPI
from nicegui import ui

app = FastAPI()

def onclick():
    print('clicked')
    ui.notify('It works!')

@ui.page('/')
def index():
    ui.button('click me', on_click=onclick)

ui.run_with(app, storage_secret="secret")

The print statement does execute but the notification never shows. This is also true if I make a change to a element and call .update, the element never does update.

Here is the manifest file used for Posit:

{
  "version": 1,
  "locale": "English_United States.1252",
  "metadata": {
    "appmode": "python-fastapi",
    "entrypoint": "app"
  },
  "python": {
    "version": "3.11.9",
    "package_manager": {
      "name": "pip",
      "version": "23.1.2",
      "package_file": "requirements.txt"
    }
  },
  "files": {
    "requirements.txt": {
      "checksum": "63586e8f5039bccf552c70317574bae1"
    },
    "app.py": {
      "checksum": "2238ee8f2f6cbf272898617fb579540b"
    }
  }
}

And here is the requirements.txt that it uses to spin up the environment:

nicegui==1.4.37
rsconnect_python==1.24.0

I am wondering if this update from Posit is part of the issue:

Shiny for Python apps using Starlette >= 0.35.0 now run correctly. (#25645)

This breakage was due to Starlette updating its usage of scope["path"]. Should ASGI frameworks change their implementation of scope["path"], the environment variable CONNECT_STRICT_ASGI can be set to true or false to force strict or non-compliant treatment of scope["path"]. Use the Vars pane to adjust environment variables for any content item.

Posit also had breakage due to the Starlette update.

UPDATE:
Managed to get this error:

2024/08/29 12:31:03 PM: disconnect async handler error
2024/08/29 12:31:03 PM: Traceback (most recent call last):
2024/08/29 12:31:03 PM: disconnect async handler error
2024/08/29 12:31:03 PM: Traceback (most recent call last):
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/engineio/async_server.py", line 483, in run_async_handler
2024/08/29 12:31:03 PM: return await self.handlersevent
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/engineio/async_server.py", line 483, in run_async_handler
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/socketio/async_server.py", line 692, in _handle_eio_disconnect
2024/08/29 12:31:03 PM: await self._handle_disconnect(eio_sid, n)
2024/08/29 12:31:03 PM: return await self.handlersevent
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/socketio/async_server.py", line 585, in _handle_disconnect
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/socketio/async_server.py", line 692, in _handle_eio_disconnect
2024/08/29 12:31:03 PM: await self._trigger_event('disconnect', namespace, sid)
2024/08/29 12:31:03 PM: await self._handle_disconnect(eio_sid, n)
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/socketio/async_server.py", line 641, in _trigger_event
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/socketio/async_server.py", line 585, in _handle_disconnect
2024/08/29 12:31:03 PM: ret = handler(*args)
2024/08/29 12:31:03 PM: await self._trigger_event('disconnect', namespace, sid)
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/nicegui/nicegui.py", line 187, in _on_disconnect
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/socketio/async_server.py", line 641, in _trigger_event
2024/08/29 12:31:03 PM: ret = handler(*args)
2024/08/29 12:31:03 PM: client.handle_disconnect()
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/nicegui/nicegui.py", line 187, in _on_disconnect
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/nicegui/client.py", line 271, in handle_disconnect
2024/08/29 12:31:03 PM: self._disconnect_task = background_tasks.create(handle_disconnect())
2024/08/29 12:31:03 PM: client.handle_disconnect()
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/nicegui/client.py", line 271, in handle_disconnect
2024/08/29 12:31:03 PM: self._disconnect_task = background_tasks.create(handle_disconnect())
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/nicegui/background_tasks.py", line 21, in create
2024/08/29 12:31:03 PM: assert core.loop is not None
2024/08/29 12:31:03 PM: File "/opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/nicegui/background_tasks.py", line 21, in create
2024/08/29 12:31:03 PM: AssertionError
2024/08/29 12:31:03 PM: assert core.loop is not None
2024/08/29 12:31:03 PM: AssertionError
2024/08/29 12:31:03 PM: /opt/rstudio-connect/mnt/app/python/env/lib64/python3.9/site-packages/engineio/async_server.py:491: RuntimeWarning: coroutine 'Client.handle_disconnect..handle_disconnect' was never awaited
2024/08/29 12:31:03 PM: return False
2024/08/29 12:31:03 PM: RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Looks like this Posit Connect update may have broken compatibility?

Fixed
Shiny for Python applications use asyncio rather than uvloop, which prevents batching of WebSocket messages. (#26938)

Posit Connect Changelogs

@falkoschindler
Copy link
Contributor

Have you tried setting the CONNECT_STRICT_ASGI environment variable as suggested in the changelog?

And I think you didn't answer my questions from above:

  • What do you mean with FastAPI 1.0.8? There is no such version.
  • Do you rely on FastAPI 0.108.x? Or is the latest 0.112.2 fine for you?
  • Could you try upgrading to a newer NiceGUI version, e.g. 2.0.1?

@falkoschindler falkoschindler added the question Further information is requested label Sep 2, 2024
@aca-trevor-winn
Copy link
Author

aca-trevor-winn commented Sep 4, 2024

I have tried CONNECT_STRICT_ASGI. When set to true it throws errors. I can grab the error log for that if thought necessary.
I ment FastAPI 0.108.x, I do not rely on 0.108.x I would like to upgrade to the latest version but in order to do that I need to upgrade nicegui which is where the problem is stemming from. I am trying to update my project to the latest version of Nicegui.

I have not tried updating to 2.0.1, I will do that and report back if anything changes.

@aca-trevor-winn
Copy link
Author

aca-trevor-winn commented Sep 4, 2024

I have tested with Nicegui 2.0.1, with CONNECT_STRICT_ASGI true and false.

Here are the logs for CONNECT_STRICT_ASGI true:

2024/09/04 8:37:25 AM: Traceback (most recent call last):
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/engineio/async_server.py", line 483, in run_async_handler
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/engineio/async_server.py", line 483, in run_async_handler
2024/09/04 8:37:25 AM:     return await self.handlers[event](*args)
2024/09/04 8:37:25 AM:     return await self.handlers[event](*args)
2024/09/04 8:37:25 AM:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/socketio/async_server.py", line 692, in _handle_eio_disconnect
2024/09/04 8:37:25 AM:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/socketio/async_server.py", line 692, in _handle_eio_disconnect
2024/09/04 8:37:25 AM:     await self._handle_disconnect(eio_sid, n)
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/socketio/async_server.py", line 585, in _handle_disconnect
2024/09/04 8:37:25 AM:     await self._handle_disconnect(eio_sid, n)
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/socketio/async_server.py", line 585, in _handle_disconnect
2024/09/04 8:37:25 AM:     await self._trigger_event('disconnect', namespace, sid)
2024/09/04 8:37:25 AM:     await self._trigger_event('disconnect', namespace, sid)
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/socketio/async_server.py", line 641, in _trigger_event
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/socketio/async_server.py", line 641, in _trigger_event
2024/09/04 8:37:25 AM:     ret = handler(*args)
2024/09/04 8:37:25 AM:     ret = handler(*args)
2024/09/04 8:37:25 AM:           ^^^^^^^^^^^^^^
2024/09/04 8:37:25 AM:           ^^^^^^^^^^^^^^
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/nicegui/nicegui.py", line 187, in _on_disconnect
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/nicegui/nicegui.py", line 187, in _on_disconnect
2024/09/04 8:37:25 AM:     client.handle_disconnect()
2024/09/04 8:37:25 AM:     client.handle_disconnect()
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/nicegui/client.py", line 255, in handle_disconnect
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/nicegui/client.py", line 255, in handle_disconnect
2024/09/04 8:37:25 AM:     self._disconnect_task = background_tasks.create(handle_disconnect())
2024/09/04 8:37:25 AM:     self._disconnect_task = background_tasks.create(handle_disconnect())
2024/09/04 8:37:25 AM:                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024/09/04 8:37:25 AM:                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/nicegui/background_tasks.py", line 21, in create
2024/09/04 8:37:25 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/nicegui/background_tasks.py", line 21, in create
2024/09/04 8:37:25 AM:     assert core.loop is not None
2024/09/04 8:37:25 AM:     assert core.loop is not None
2024/09/04 8:37:25 AM:            ^^^^^^^^^^^^^^^^^^^^^
2024/09/04 8:37:25 AM:            ^^^^^^^^^^^^^^^^^^^^^
2024/09/04 8:37:25 AM: AssertionError
2024/09/04 8:37:25 AM: AssertionError
2024/09/04 8:37:25 AM: /opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/engineio/async_server.py:488: RuntimeWarning: coroutine 'Client.handle_disconnect.<locals>.handle_disconnect' was never awaited
2024/09/04 8:37:25 AM:   if event == 'connect':
2024/09/04 8:37:25 AM: RuntimeWarning: Enable tracemalloc to get the object allocation traceback
2024/09/04 8:37:45 AM: clicked
2024/09/04 8:37:45 AM: clicked
2024/09/04 8:38:37 AM: [rsc-session] Received signal: interrupt
2024/09/04 8:38:37 AM: [rsc-session] Terminating subprocess with interrupt ...
2024/09/04 8:38:37 AM: disconnect async handler error
2024/09/04 8:38:37 AM: Traceback (most recent call last):
2024/09/04 8:38:37 AM: disconnect async handler error
2024/09/04 8:38:37 AM: Traceback (most recent call last):
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/engineio/async_server.py", line 483, in run_async_handler
2024/09/04 8:38:37 AM:     return await self.handlers[event](*args)
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/engineio/async_server.py", line 483, in run_async_handler
2024/09/04 8:38:37 AM:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024/09/04 8:38:37 AM:     return await self.handlers[event](*args)
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/socketio/async_server.py", line 692, in _handle_eio_disconnect
2024/09/04 8:38:37 AM:     await self._handle_disconnect(eio_sid, n)
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/socketio/async_server.py", line 585, in _handle_disconnect
2024/09/04 8:38:37 AM:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/socketio/async_server.py", line 692, in _handle_eio_disconnect
2024/09/04 8:38:37 AM:     await self._trigger_event('disconnect', namespace, sid)
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/socketio/async_server.py", line 641, in _trigger_event
2024/09/04 8:38:37 AM:     await self._handle_disconnect(eio_sid, n)
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/socketio/async_server.py", line 585, in _handle_disconnect
2024/09/04 8:38:37 AM:     await self._trigger_event('disconnect', namespace, sid)
2024/09/04 8:38:37 AM:     ret = handler(*args)
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/socketio/async_server.py", line 641, in _trigger_event
2024/09/04 8:38:37 AM:           ^^^^^^^^^^^^^^
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/nicegui/nicegui.py", line 187, in _on_disconnect
2024/09/04 8:38:37 AM:     ret = handler(*args)
2024/09/04 8:38:37 AM:           ^^^^^^^^^^^^^^
2024/09/04 8:38:37 AM:     client.handle_disconnect()
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/nicegui/client.py", line 255, in handle_disconnect
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/nicegui/nicegui.py", line 187, in _on_disconnect
2024/09/04 8:38:37 AM:     client.handle_disconnect()
2024/09/04 8:38:37 AM:     self._disconnect_task = background_tasks.create(handle_disconnect())
2024/09/04 8:38:37 AM:                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/nicegui/client.py", line 255, in handle_disconnect
2024/09/04 8:38:37 AM:     self._disconnect_task = background_tasks.create(handle_disconnect())
2024/09/04 8:38:37 AM:                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/nicegui/background_tasks.py", line 21, in create
2024/09/04 8:38:37 AM:   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.11/site-packages/nicegui/background_tasks.py", line 21, in create
2024/09/04 8:38:37 AM:     assert core.loop is not None
2024/09/04 8:38:37 AM:     assert core.loop is not None
2024/09/04 8:38:37 AM:            ^^^^^^^^^^^^^^^^^^^^^
2024/09/04 8:38:37 AM:            ^^^^^^^^^^^^^^^^^^^^^
2024/09/04 8:38:37 AM: AssertionError
2024/09/04 8:38:37 AM: AssertionError
2024/09/04 8:38:37 AM: [rsc-session] Terminated subprocess with signal: interrupt

Here are the logs for CONNECT_STRICT_ASGI false:

2024/09/04 8:38:38 AM: Environment variable CONNECT_STRICT_ASGI is 'false'; forcing non-strict ASGI 'path'
2024/09/04 8:38:38 AM: Starting server...
2024/09/04 8:38:39 AM: http://127.0.0.1:44215/_nicegui/2.0.1/static/nicegui.css not found
2024/09/04 8:38:39 AM: http://127.0.0.1:44215/_nicegui/2.0.1/static/fonts.css not found
2024/09/04 8:38:39 AM: http://127.0.0.1:44215/_nicegui/2.0.1/static/tailwindcss.min.js not found
2024/09/04 8:38:39 AM: http://127.0.0.1:44215/_nicegui/2.0.1/static/quasar.umd.prod.js not found
2024/09/04 8:38:39 AM: http://127.0.0.1:44215/_nicegui/2.0.1/static/es-module-shims.js not found
2024/09/04 8:38:39 AM: http://127.0.0.1:44215/_nicegui/2.0.1/static/lang/en-US.umd.prod.js not found
2024/09/04 8:38:39 AM: http://127.0.0.1:44215/_nicegui/2.0.1/static/socket.io.min.js not found
2024/09/04 8:38:39 AM: http://127.0.0.1:44215/_nicegui/2.0.1/static/quasar.prod.css not found
2024/09/04 8:38:39 AM: http://127.0.0.1:44215/_nicegui/2.0.1/static/vue.global.prod.js not found
2024/09/04 8:38:39 AM: http://127.0.0.1:44215/_nicegui/2.0.1/static/nicegui.js not found
2024/09/04 8:40:39 AM: Traceback (most recent call last):
2024/09/04 8:40:39 AM: disconnect async handler error
2024/09/04 8:40:39 AM: Traceback (most recent call last):

@falkoschindler falkoschindler added help wanted Extra attention is needed and removed question Further information is requested labels Sep 6, 2024
@falkoschindler
Copy link
Contributor

Ok, we're out of ideas. This might be a problem specific to Posit Connect. Does anyone from the community have an idea what could be causing the issue?

@aca-trevor-winn
Copy link
Author

I downloaded nicegui source and added it to my test project, I can't use debug on the posit server but I am using print statements to find the source of the incompatibility. The loop for the client inbox is not running it seems, I am investigating further.

@aca-trevor-winn
Copy link
Author

After some testing I have kinda hit a roadblock and could use some guidance. What I have come to terms with is when the Strict Scope path is set the nicegui lifespan context manager never gets called and so the startup operations never fire, like the outbox loop. But when the scope path is set to false, the lifespan DOES work BUT it cant mount the static files. Sorry for the delayed response, I am based on SC and the hurricane moved my priorities.
I havent been able to figure out why it doesnt call the nicegui lifespan yet and I am not sure where to continue looking.

@aca-trevor-winn
Copy link
Author

The plot thickens. I have managed to get it WORKING "KINDA". I switched the CONNECT_STRICT_ASGI to false and then in a stroke of luck decided to make this change:
image
Changing from mount to add static files let the static files load. I am not sure why this worked, could someone explain what the difference is so we might be able to get this fixed for everyone. let me know if there is any additional information I could provide.

@rodja
Copy link
Member

rodja commented Nov 4, 2024

The mount version is a bit simpler to maintain and generally faster. But it bypasses FastAPI's routing layer as far as I know. So there might be subtle differences which lead to your error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants