Skip to content

A self-chaining event loop started from on_load keeps running after the client disconnects, logging "Attempting to send delta to disconnected client" once per tick #7251

Closed

Description

@masenf

Describe the bug

An on_load handler that re-yields itself (a poll loop) is not cancelled when the client goes away mid-loop. It runs server-side to completion and logs Warning: Attempting to send delta to disconnected client once per tick (44 times for the campaign's loop). #6593's supersedes=True on on_load_internal cancels the previous page's chain when the same token loads the next page, but a plain disconnect (tab closed, reload before the socket reconnects, navigation to a non-reflex page) leaves the chain running.

Side effect worth knowing: those undelivered deltas are recorded as sent by #6946's dedupe memo. That is safe today only because the reconnect path re-hydrates via dict().

To Reproduce

class S(rx.State):
    ticks: int = 0

    @rx.event
    async def tick(self):
        for _ in range(60):
            self.ticks += 1
            yield
            await asyncio.sleep(0.5)

# page: on_load=S.tick

Load the page, close the tab (or reload) after a few ticks, watch the server log.

Observed behavior

The loop runs to the end; one Attempting to send delta to disconnected client warning per remaining tick.

Expected behavior

Cancel a chain whose client disconnected (or at least stop emitting for it and log once), or document the pattern and the intended way to stop such a loop.

Specifics

  • Reflex 0.9.12a1; pre-existing family, also on 0.9.11.post1
  • Python 3.11.15, Linux

Additional context

0.9.12a1 pre-release QA, event_loop cluster, anomaly 4. Related: #6593 (the navigation case, fixed), #7239 (detached events, a different ask). Evidence in event_loop/: logs/dev_warnings.txt, NOTES.md. Full write-up: FINDINGS.md.

Activity

  1. added theissue type on Sep 22, 2026
  2. linear-code commented on Sep 22, 2026

    @linear-code
  3. added
    release-train
    on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    release-train

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions