Skip to content

Test supersede chained background tasks - #4

Open
tim-haselhoff wants to merge 7 commits into
mainfrom
test-supersede-chained-background-tasks
Open

Test supersede chained background tasks#4
tim-haselhoff wants to merge 7 commits into
mainfrom
test-supersede-chained-background-tasks

Conversation

@tim-haselhoff

Copy link
Copy Markdown
Owner

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

After these steps, you're ready to open a pull request.

a. Give a descriptive title to your PR.

b. Describe your changes.

c. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such).

FarhanAliRaza and others added 7 commits July 7, 2026 03:29
Navigating away while a page's on_load chain is still running left the
stale chain executing, blocking the new page's events behind it and
applying its late deltas (reflex-dev#6593).

Add a SUPERSEDES_MARKER for event handlers with latest-wins semantics:
enqueuing a new chain-root invocation cancels the previous unfinished
event chain rooted at the same handler for the same client token. Mark
on_load_internal with it so a newer navigation supersedes the previous
page's unfinished load.

The EventProcessor tracks the active chain root per (event name, token),
drops events chained from an already-cancelled parent before they enter
the queue, and defers future cleanup while the handler task is still
unwinding so late-chained events can find their cancelled parent.
- expose supersedes as a kwarg on rx.event and mark on_load_internal
  with @event(supersedes=True) instead of post-class setattr
- only retain cancelled futures in _futures while their task unwinds, so
  the backend exception handler task can chain recovery events (with
  regression test)
- drop the redundant eager _try_clean_future calls in the dispatch paths;
  the future's done callback already handles cleanup
- reword cancelled-chain comment
- make _drain_superseded fail loudly instead of silently giving up
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

Successfully merging this pull request may close these issues.

2 participants