Skip to content

Drain queued propchange events on reconnect#120

Merged
DmitrySharabin merged 3 commits into
rollback-signalsfrom
fix-propchange-drain-on-reconnect
May 17, 2026
Merged

Drain queued propchange events on reconnect#120
DmitrySharabin merged 3 commits into
rollback-signalsfrom
fix-propchange-drain-on-reconnect

Conversation

@DmitrySharabin
Copy link
Copy Markdown
Member

@DmitrySharabin DmitrySharabin commented May 15, 2026

Summary

Replaces the implicit isConnected queue check with an explicit pauseEvents / resumeEvents primitive on Props, gated by a #paused WeakSet. Lifecycle hooks wire disconnected → pauseEvents and connected → resumeEvents — same fix, first-class primitive for #51 batching to build on.

Addresses Lea's review.

Tests

96/102 PASS locally (4 pre-existing skipped). The original reconnect regression test is unchanged. One new test covers the primitive directly: pause → writes → resume, asserting no dispatch during pause and ordered drain on resume.

The 2 reds (Post-mount setAttribute…, removeAttribute collapses…) are owned by #117 and will go green once it merges — this PR deliberately doesn't carry that commit.

@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch 2 times, most recently from 5c64952 to 7907d85 Compare May 15, 2026 14:52
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-source-first-order branch from 70c36ac to c4e3cf8 Compare May 15, 2026 17:52
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from 7907d85 to 13367a4 Compare May 15, 2026 17:52
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-source-first-order branch from c4e3cf8 to 05ccdb9 Compare May 15, 2026 18:05
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from 13367a4 to 98d136f Compare May 15, 2026 18:06
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-source-first-order branch from 05ccdb9 to d1d74a5 Compare May 15, 2026 18:08
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from 98d136f to e76d161 Compare May 15, 2026 18:08
Copy link
Copy Markdown
Contributor

@LeaVerou LeaVerou left a comment

Choose a reason for hiding this comment

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

"drain" reads more like an implementation detail than a user-facing concept. Plus, drain what? It's missing context.

I think it would be useful to make these first-class concepts, with a method to stop dispatching events and another one to resume and drain, and frame around that. I suspect this could also be more efficient, though I haven't seen the code that adds to queue to verify. And I can certainly see that being useful in other situations as well.

@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from b8022d0 to 520b067 Compare May 15, 2026 20:47
DmitrySharabin added a commit that referenced this pull request May 15, 2026
Per review feedback on #120: 'drain' reads as an implementation detail
and lacks context. The new name says what the method dispatches and that
they were queued, matching the existing eventDispatchQueue field.
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from da9a76c to 25112e1 Compare May 15, 2026 21:34
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-source-first-order branch from d1d74a5 to 08e199b Compare May 15, 2026 21:34
DmitrySharabin added a commit that referenced this pull request May 15, 2026
Per review feedback on #120: 'drain' reads as an implementation detail
and lacks context. The new name says what the method dispatches and that
they were queued, matching the existing eventDispatchQueue field.
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-source-first-order branch from 08e199b to d1d74a5 Compare May 15, 2026 21:41
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from 25112e1 to da9a76c Compare May 15, 2026 21:41
DmitrySharabin added a commit that referenced this pull request May 15, 2026
Per review feedback on #120: 'drain' reads as an implementation detail
and lacks context. The new name says what the method dispatches and that
they were queued, matching the existing eventDispatchQueue field.
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from da9a76c to fd394ef Compare May 15, 2026 21:45
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-source-first-order branch from d1d74a5 to e163920 Compare May 15, 2026 21:45
DmitrySharabin added a commit that referenced this pull request May 15, 2026
Per review feedback on #120: 'drain' reads as an implementation detail
and lacks context. The new name says what the method dispatches and that
they were queued, matching the existing eventDispatchQueue field.
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from fd394ef to f8bedf0 Compare May 15, 2026 22:03
DmitrySharabin added a commit that referenced this pull request May 15, 2026
Per review feedback on #120: 'drain' reads as an implementation detail
and lacks context. The new name says what the method dispatches and that
they were queued, matching the existing eventDispatchQueue field.
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-source-first-order branch from 3625381 to f7356e7 Compare May 15, 2026 22:07
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from f8bedf0 to afd9438 Compare May 15, 2026 22:07
DmitrySharabin added a commit that referenced this pull request May 16, 2026
Per review feedback on #120: 'drain' reads as an implementation detail
and lacks context. The new name says what the method dispatches and that
they were queued, matching the existing eventDispatchQueue field.
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from afd9438 to d2d4b7a Compare May 16, 2026 12:01
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-source-first-order branch from f7356e7 to 5d2dac7 Compare May 16, 2026 12:01
Base automatically changed from fix-propchange-source-first-order to fix-issue-98 May 16, 2026 12:01
DmitrySharabin added a commit that referenced this pull request May 16, 2026
Per review feedback on #120: 'drain' reads as an implementation detail
and lacks context. The new name says what the method dispatches and that
they were queued, matching the existing eventDispatchQueue field.
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from d2d4b7a to 589ad50 Compare May 16, 2026 12:05
@DmitrySharabin
Copy link
Copy Markdown
Member Author

Done — reframed as pauseEvents / resumeEvents on Props, gated by a #paused WeakSet. Lifecycle hooks call them directly, so reconnect still drains and the same primitive is ready for #51 batching to build on. Coalescing is intentionally out of scope here to keep the PR minimal.

@DmitrySharabin DmitrySharabin changed the base branch from fix-issue-98 to rollback-signals May 16, 2026 15:52
DmitrySharabin and others added 2 commits May 16, 2026 17:56
Events fired while the element is disconnected are queued in
firePropChangeEvent. Previously, the queue only drained in
Props.initializeFor, which runs from the once-per-element `constructed`
hook — so events queued during a disconnect→reconnect cycle were lost.

Extract the inline drain into Props.drainFor and call it from a new
`connected` hook in props/index.js. The hook fires on every connect; on
first connect the queue is already empty after initializeFor's drain,
so no double-dispatch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per review feedback on #120: 'drain' reads as an implementation detail
and lacks context. The new name says what the method dispatches and that
they were queued, matching the existing eventDispatchQueue field.
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from 1b7c407 to d3109eb Compare May 16, 2026 15:57
Replaces the implicit isConnected check with an explicit #paused
WeakSet, exposed via pauseEvents/resumeEvents on Props. Lifecycle
hooks wire disconnected → pauseEvents, connected → resumeEvents.
Foundation for manual batching (#51).
@DmitrySharabin DmitrySharabin force-pushed the fix-propchange-drain-on-reconnect branch from d3109eb to c1a7bff Compare May 16, 2026 16:01
@DmitrySharabin DmitrySharabin requested a review from LeaVerou May 16, 2026 16:03
Copy link
Copy Markdown
Contributor

@LeaVerou LeaVerou left a comment

Choose a reason for hiding this comment

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

We should coalesce, but this can be done in a separate PR

@DmitrySharabin DmitrySharabin merged commit dfe8f61 into rollback-signals May 17, 2026
@DmitrySharabin DmitrySharabin deleted the fix-propchange-drain-on-reconnect branch May 17, 2026 20:11
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