Skip to content

Conversation

@samwillis
Copy link
Contributor

This exposes the ShapeStream.fetchSnapshot as a public api that can be used to fetch a snapshot without it being injected into the emitted stream of change messages. This is useful for cases where the user wants to handle the application of these snapshot in a custom way, as we need to in Tanstack DB for the progressive mode.

While working on this I also took the opportunity to tidy up the parsing of the messages, in the old implementation we would JSON.stringify the messages, only to the parse them again. I refactored the parser to be able to work on already parsed (JSON -> basic JS) messages.

First commit is the core change to expose fetchSnapshot, second commit is the refactor of message parsing.

@samwillis samwillis requested a review from kevin-dp November 19, 2025 09:38
@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.64%. Comparing base (6bb011b) to head (e1cf8b8).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
packages/typescript-client/src/parser.ts 82.35% 3 Missing ⚠️
packages/typescript-client/src/client.ts 88.88% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3463      +/-   ##
==========================================
+ Coverage   67.45%   67.64%   +0.18%     
==========================================
  Files         180      180              
  Lines        9671     9693      +22     
  Branches      359      365       +6     
==========================================
+ Hits         6524     6557      +33     
+ Misses       3145     3134      -11     
  Partials        2        2              
Flag Coverage Δ
elixir 64.16% <ø> (+0.12%) ⬆️
elixir-client 73.94% <ø> (-0.53%) ⬇️
packages/experimental 88.95% <ø> (+1.22%) ⬆️
packages/react-hooks 86.48% <ø> (ø)
packages/typescript-client 93.60% <85.71%> (+0.03%) ⬆️
packages/y-electric 55.12% <ø> (ø)
postgres-140000 62.95% <ø> (+0.12%) ⬆️
postgres-150000 62.97% <ø> (?)
postgres-170000 62.71% <ø> (-0.08%) ⬇️
postgres-180000 62.89% <ø> (+0.25%) ⬆️
sync-service 63.17% <ø> (+0.19%) ⬆️
typescript 87.32% <85.71%> (+0.25%) ⬆️
unit-tests 67.64% <85.71%> (+0.18%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 19, 2025

Open in StackBlitz

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

commit: e1cf8b8

@samwillis samwillis merged commit aacfba4 into main Nov 19, 2025
57 of 58 checks passed
@samwillis samwillis deleted the samwillis/expose-fetch-snapshot branch November 19, 2025 14:29
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.

3 participants