electric icon indicating copy to clipboard operation
electric copied to clipboard

Remove invalid subset loading check

Open KyleAMathews opened this issue 1 month ago • 2 comments

Removed the check that prevented requestSnapshot from being called in full mode. It's valid to load subsets while loading the full log, which is necessary for LiveQuery joins with collections using progressive syncMode.

Fixes the error: "Snapshot requests are not supported in full mode, as the consumer is guaranteed to observe all data"

KyleAMathews avatar Nov 14 '25 17:11 KyleAMathews

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 69.54%. Comparing base (f41db22) to head (cb91c91). :warning: Report is 21 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3436      +/-   ##
==========================================
+ Coverage   69.45%   69.54%   +0.08%     
==========================================
  Files         182      182              
  Lines        9787     9786       -1     
  Branches      356      358       +2     
==========================================
+ Hits         6798     6806       +8     
+ Misses       2987     2978       -9     
  Partials        2        2              
Flag Coverage Δ
elixir 66.51% <ø> (+0.09%) :arrow_up:
elixir-client 74.47% <ø> (+0.52%) :arrow_up:
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/typescript-client 93.76% <ø> (+0.08%) :arrow_up:
packages/y-electric 55.12% <ø> (ø)
postgres-140000 65.28% <ø> (-0.21%) :arrow_down:
postgres-150000 65.52% <ø> (+0.21%) :arrow_up:
postgres-170000 65.35% <ø> (-0.05%) :arrow_down:
postgres-180000 65.45% <ø> (?)
sync-service 65.72% <ø> (+0.05%) :arrow_up:
typescript 87.18% <ø> (+0.05%) :arrow_up:
unit-tests 69.54% <ø> (+0.08%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Nov 14 '25 17:11 codecov[bot]

Open in StackBlitz

npm i https://pkg.pr.new/@electric-sql/react@3436
npm i https://pkg.pr.new/@electric-sql/client@3436
npm i https://pkg.pr.new/@electric-sql/y-electric@3436

commit: cb91c91

pkg-pr-new[bot] avatar Nov 14 '25 17:11 pkg-pr-new[bot]

Should we have an e2e test for this?

kevin-dp avatar Nov 17 '25 10:11 kevin-dp

Out of curiosity, what's the use of a snapshot in a full mode, given the client already holds all the same data?

icehaunter avatar Nov 17 '25 10:11 icehaunter

@icehaunter for the "progressive mode" https://tanstack.com/blog/tanstack-db-0.5-query-driven-sync#progressive-sync-fast-initial-paint--instant-client-queries

@kevin-dp you mean in the tanstack db repo?

KyleAMathews avatar Nov 17 '25 14:11 KyleAMathews

@KyleAMathews This will not fix the issue with Tanstack DB progressive mode, we need to fix it on the DB side rather than on the Electric Client side.

The electric client ensures that the results of a requestSnapshot call are injected into the shape stream at the point where they are causally correct - this is important for on-demand mode in DB to insure that live updates are applied on top of the snapshot and it does not overwrite newer changes. With this fix the snapshots will still not be injected until the end of the stream, not optimistically as we would like.

The intention of progressive mode is that while the initial sync is happening we use and show snapshots. We need to have a discussion on this mode as currently nothing is applied to the collection until the first up-to-date.

samwillis avatar Nov 17 '25 14:11 samwillis

@icehaunter for the "progressive mode" https://tanstack.com/blog/tanstack-db-0.5-query-driven-sync#progressive-sync-fast-initial-paint--instant-client-queries

@kevin-dp you mean in the tanstack db repo?

No, I got the general idea, I'm just not sure why additional snapshots are needed on top of already full data. I thought the idea for progressive mode was to only use these subset snapshots, otherwise it seems to make little sense if the client already has all the data. Am I missing something?

icehaunter avatar Nov 17 '25 14:11 icehaunter

@icehaunter

I'm just not sure why additional snapshots are needed on top of already full data

DB progressive mode is supposed to show the snapshots before we load all the data. on-demand is working with the new scheme perfectly.

samwillis avatar Nov 17 '25 14:11 samwillis