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

Hot reload results in multiple websocket connections #4566

Open
masenf opened this issue Dec 20, 2024 · 1 comment
Open

Hot reload results in multiple websocket connections #4566

masenf opened this issue Dec 20, 2024 · 1 comment

Comments

@masenf
Copy link
Collaborator

masenf commented Dec 20, 2024

Describe the bug
Something about how the nextjs hot reload injects changes into the running app causes websockets to leak when updates are applied quickly.

To Reproduce

  1. Create a blank app and add some stateful component to enable the websocket.
  2. reflex run the app in dev mode.
  3. Open http://localhost:3000 in browser.
  4. Make several changes back to back saving each time.
import reflex as rx

def index() -> rx.Component:
    return rx.container(
        rx.vstack(
            rx.text(rx.State.router.page.full_path),
            rx.text(rx.State.router.session.session_id),
            rx.text(rx.State.router.session.client_token),
        ),
    )


app = rx.App()
app.add_page(index)

Expected behavior
Expect that afterwards, only a single websocket connection to /_event is open.

Actually there are many websocket connections open for the tab, but only one seems to actually be active. The others are just hanging around, wasting resources.

Thankfully this doesn't seem to affect prod mode, because there is no hot-reload in prod.

Screenshots
image

Why are there 3 open connections to /_event?????

Specifics (please complete the following information):

  • Python Version: 3.12
  • Reflex Version: 0.6.7
  • OS: macOS
@masenf masenf changed the title Multiple hot reloads in quick succession results in multiple websocket connections Hot reloads in results in multiple websocket connections Dec 20, 2024
@masenf masenf changed the title Hot reloads in results in multiple websocket connections Hot reload results in multiple websocket connections Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant