Skip to content

fix(core): do not store a snapshot when every reducer skips - #810

Open
o-mid wants to merge 1 commit into
theam:mainfrom
o-mid:fix/skip-unchanged-snapshot
Open

o-mid wants to merge 1 commit into
theam:mainfrom
o-mid:fix/skip-unchanged-snapshot

Conversation

@o-mid

@o-mid o-mid commented Sep 28, 2026 •

Copy link
Copy Markdown

Summary

fetchEntitySnapshot stored the loaded snapshot again when every pending reducer returned ReducerAction.Skip, and also when a pending event was handed to the global error handler and processing continued. The stored copy keeps the old snapshottedEventCreatedAt, so the write does not move the snapshot forward. The method now returns the loaded snapshot and skips the write unless a reducer produced a new snapshot.

A mix of skip and reduce still stores the reduced snapshot. An empty pending stream already returned without a write, and that path is unchanged.

Semver: patch. The method signature is the same. Callers see fewer snapshot writes when nothing changed.

Fixes #700

Test plan

  • The updated skip test failed on main before the fix (storeSnapshot was still called)
  • cd packages/core && rushx test (332 passing)
  • cd packages/core && rushx lint:fix

fetchEntitySnapshot wrote the loaded snapshot back when every pending event returned ReducerAction.Skip. That write copies the same data and does not move the snapshot cursor. Store a snapshot only when a reducer produced a new one.

Fixes theam#700

This branch has not been deployed

No deployments
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.

Avoid storing unchanged snapshot when all reducers skip events (potential for snapshot bloat)

1 participant