Skip to content

Page will refresh after a network offline and online #5409

@programus

Description

@programus

First Check

  • I added a very descriptive title here.
  • This is not a Q&A. I am sure something is wrong with NiceGUI or its documentation.
  • I used the GitHub search to find a similar issue and came up empty.

Example Code

# copy from https://nicegui.io/documentation/page#wait_for_client_connection

import asyncio
from nicegui import ui

@ui.page('/wait_for_connection')
async def wait_for_connection():
    ui.label('This text is displayed immediately.')
    await ui.context.client.connected()
    await asyncio.sleep(2)
    ui.label('This text is displayed 2 seconds after the page has been fully loaded.')

@ui.page('/')
def page():
    ui.link('wait for connection', wait_for_connection)

ui.run()

Description

  1. Access https://nicegui.io/wait_for_connection , which is running the example code.
  2. Break the network connection to the server for several seconds. (Or simulate it by browser's dev tool > Network tab)
  3. Restore the network connection again.
  4. The page would refresh automatically with a message, reloading because handshake failed for clientId <uuid> in the console. While I expect it remains the same without any refreshing since I haven't touched it at all and nothing happening should be normal.

Usually, this does not affect so much, but this would be critical for the users with an unstable Internet connection.

I suppose all the code for a page should be only triggered while user access the specified page.

NiceGUI Version

3.1.0 (I am not sure whether this is the same as the NiceGUI document)

Python Version

3.12.10 (I am not sure whether this is the same as the NiceGUI document)

Browser

Other, Chrome

Operating System

macOS

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    analysisStatus: Requires team/community input

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions