Skip to content

Event processor fix - #6801

Merged
masenf merged 4 commits into
reflex-dev:mainfrom
benedikt-bartscher:event-processor-fix
Aug 28, 2026
Merged

Event processor fix#6801
masenf merged 4 commits into
reflex-dev:mainfrom
benedikt-bartscher:event-processor-fix

Conversation

@benedikt-bartscher

Copy link
Copy Markdown
Contributor

No description provided.

@codspeed-hq

codspeed-hq Bot commented Jul 19, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing benedikt-bartscher:event-processor-fix (cbccaad) with main (f7c848f)2

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (45b8ed5) during the generation of this report, so f7c848f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@greptile-apps

greptile-apps Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a RuntimeError crash that occurred when an event was chained from a parent event handler that had already completed. The fix adds a not parent_future.done() guard before calling parent_future.add_child(tracked), allowing late-chained events to proceed independently rather than crashing.

  • The ordering of checks is correct: the existing cancelled() early-return is evaluated first, so the new done() guard specifically covers parent futures that completed with a result or exception; the late-chained child still gets enqueued and executes normally.
  • The regression test directly reproduces the failure scenario by inserting a pre-completed EventFuture and asserting no crash, correct execution of the late child, and an empty children list on the done parent.

Confidence Score: 5/5

  • This is a small, targeted guard in the event-enqueue path that prevents a crash without altering any other behaviour.
  • The change is minimal and well-understood: one conditional wrapping a single method call, backed by a direct regression test that covers the exact failure scenario. Callers who awaited the parent via wait_all() before the late child was enqueued won't see any change; callers who crashed before will now succeed. No data-path side effects were introduced.
  • No files require special attention.

Important Files Changed

Filename Overview
packages/reflex-base/src/reflex_base/event/processor/event_processor.py Adds a not parent_future.done() guard before add_child, preventing a RuntimeError when a late-chained event tries to register under an already-completed parent future. Logic is correct: cancelled futures are handled first (early return), so the new check only fires when the parent completed with a result or exception.
tests/units/reflex_base/event/processor/test_event_processor.py Adds a targeted regression test that manually inserts a completed parent EventFuture into the processor's _futures dict and verifies (1) no crash, (2) the late-chained event actually executes, and (3) the done parent's children list stays empty.
packages/reflex-base/news/6801.bugfix.md Changelog entry accurately describes the fixed crash and the new behaviour for late-chained events.

Reviews (3): Last reviewed commit: "add changelog" | Re-trigger Greptile

@benedikt-bartscher
benedikt-bartscher marked this pull request as ready for review August 28, 2026 13:46
@benedikt-bartscher
benedikt-bartscher requested a review from a team as a code owner August 28, 2026 13:46

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

@masenf
masenf merged commit dd96aea into reflex-dev:main Aug 28, 2026
111 checks passed
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