Repository navigation
fix: drop a replaced caller's delayed actions once a newer result arrives - #326
Merged
Merged
Conversation
JuroOravec
force-pushed
the
fix/remounted-call-delayed-actions
branch
from
October 24, 2026 15:24
24832a9 to
5123d91
Compare
…ives When an Events handler's Render replaced its component, the bridge marked the call as having remounted its own sender and kept running its later actions, so a delayed wait=False Dispatch, URL change or State refresh still ran after the page accepted a newer result from the component that replaced it. The check compared only the retired instance's count of accepted results, which the new component's results never raise. The bridge now also counts the results it accepted at each spot on the page (stableId), whichever instance is mounted there, and records the count when a call's own result is accepted. After that call's Render replaced the caller, a delayed action other than Redirect runs only while the count is unchanged. With no newer result, the delayed actions still run, as before. An applyActions on the new component counts once its citry:events:before listeners let it apply, and dispose() clears the counts. A delayed Redirect now survives a newer result in every case, with or without a replacement: it reports a result the server already produced. Like every action of a cancelled call, it is dropped when its call is superseded, its caller is removed, or the client is disposed. The Events spec's "Order and timing" section states the two rules once (a cancelled call changes nothing on the page; a newer result drops the rest of an older one, except a redirect), then gives one table of what happens in each case and the details: error results count, only results for the component at the caller's place count, actions listed before the Render, applyActions, and unknown action types. The browser APIs page and the actions page say when a delayed action is dropped. The superseded row describes the behavior from the #306 fix (#324). Fixes #307 Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec
force-pushed
the
fix/remounted-call-delayed-actions
branch
from
October 24, 2026 15:24
5123d91 to
db39fe8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #307
What changes
A handler's
Rendercan replace its own component while the same response also schedules a delayed action withwait=False. If the page then accepted a newer result from the component that replaced it, the old call's delayed action still ran on the new component, after the newer result. ADispatch, a URL change and a State refresh all behaved this way.The cause: the bridge compared only the retired instance's count of accepted results, and the new component's results never raise that count.
Fix, in
packages/js/citry-client/src/citry-events-vue.ts:stableId), whatever instance is mounted there. When a call's own result is accepted, the bridge records that count on the call.applyActionson the new component also counts, once itscitry:events:beforelisteners let it apply.dispose()clears the counts.A delayed
Redirectsurvives a newer result in every case, with or without a replacement. It reports a result the server already produced, such as "saved, now go to the list". Like every action of a cancelled call, it is still dropped when its call is superseded, when its caller is removed, or when the client is disposed. This was the maintainer's decision for this issue.Spec and docs
The "Order and timing" section of
packages/protocol/events/v1/spec.mdnow starts with the two rules, once:A single table then says what happens to a delayed action in each case. A list of details follows:
applyActions.The protocol version stays at 1.
The
epochrow indocs_site/content/reference/browser-apis.md, and the toast example indocs_site/content/events/actions.md, now say when a delayed action is dropped.Tests
There are 8 new tests in
packages/js/citry-client/test/vue-events.test.mjs. With a newer result after a replacement:Also covered:
applyActionson the new component counts as a newer result.The four drop tests fail on main's bridge (which includes #324). The
applyActionstest fails without its counter bump. The other tests guard behaviour that is kept. The attachment acceptance path has no test of its own, becausesaveAttachmentneeds DOM stubs.Evidence
These non-cargo phases of
scripts/check.pywere run by hand locally, and all pass:uv lock --check, ruff check, ruff format --check;--platform linux;scripts/validate.py.PR CI runs pytest and the cargo phases. This change has no Python logic and no Rust.
Review
An independent adversarial review ran three rounds, each with a prose pass. Its findings are folded in:
applyActions, unknown types, the blocking claim, error results);applyActionsthat abeforelistener cancelled still counted as a newer result;🤖 Generated with Claude Code