Repository navigation
fix(store): resend the NgRx action log after the server forgets the page - #251
Merged
Merged
Conversation
The page sends only log entries newer than the seq the server last confirmed. When the server forgot the page (pagehide or a bfcache restore, the 15 second expiry while the socket was down, a hub restart), the next push carried only the newest entries. The server stored them as the whole log, marked every earlier seq as dropped, and answered the newest seq, so the page never resent the history it still held. Reports now carry the seq they continue from. When the server has no record of that page session, it answers 0, and the page pushes its full held log again.
Contributor
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
7 of 8 tasks
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.
What and why
The NgRx overlay keeps up to
maxLogaction log entries, but each push sends only the entries newer thansentSeq, the seq the server last answered. When the server no longer has the page,mergeNgrxReporttreats those few entries as the whole log. It stores them, setsdroppedto every earlier seq, and answers the newest seq. The page then thinks everything was delivered and never resends the older entries it still holds.The server forgets a page in a few everyday ways:
forget-ngrx-pageonpagehide, including a bfcache restoreIf the next push carries any new action, which is nearly always the case with polling effects or socket-driven actions, the earlier history is gone for good. The Store page and the NgRx agent tools show a log starting at the latest action, with "N older actions were dropped".
The fix:
NgrxPageReportgets an optionalsince: the seq the page's report continues from.mergeNgrxReportchecks for that: when it has no record of this page session butsince > 0, it knows it lost the page. It stores no partial log and answers0.How it was verified
Added a test to
ngrx-collector.test.tswith the real Store DevTools setup and the realmergeNgrxReportbehind the RPC. It pushes two actions, callsleave()(the server forgets the page), dispatches a third action, and pushes. Onmainthe server ends up with[3](expected [ 3 ] to deeply equal [ 1, 2, 3 ]) anddropped: 2. With the fix it has[1, 2, 3]anddropped: 0.pnpm commit:check(commit messages follow the guidelines)pnpm format:checkpnpm typecheck(includes thengctemplate checks)pnpm test:devtools(all passing)pnpm skills:check(when.claude/changed): not changedno-docs)pnpm extension:buildandextension/uicommitted (whenapp/changed): not changedNotes for reviewers
sinceis optional. An older overlay that doesn't send it gets the old behavior.Summary by CodeRabbit