Skip to content

expose ShapeStream.fetchSnapshot as public api - #3463

Merged
samwillis merged 4 commits into
mainfrom
samwillis/expose-fetch-snapshot
Nov 19, 2025
Merged

expose ShapeStream.fetchSnapshot as public api#3463
samwillis merged 4 commits into
mainfrom
samwillis/expose-fetch-snapshot

Conversation

@samwillis

Copy link
Copy Markdown
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.

@codecov

codecovBot commented Nov 19, 2025

Copy link
Copy Markdown

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 linesPatch %Lines
packages/typescript-client/src/parser.ts82.35%3 Missing ⚠️
packages/typescript-client/src/client.ts88.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 
FlagCoverage Δ
elixir64.16% <ø> (+0.12%)⬆️
elixir-client73.94% <ø> (-0.53%)⬇️
packages/experimental88.95% <ø> (+1.22%)⬆️
packages/react-hooks86.48% <ø> (ø)
packages/typescript-client93.60% <85.71%> (+0.03%)⬆️
packages/y-electric55.12% <ø> (ø)
postgres-14000062.95% <ø> (+0.12%)⬆️
postgres-15000062.97% <ø> (?)
postgres-17000062.71% <ø> (-0.08%)⬇️
postgres-18000062.89% <ø> (+0.25%)⬆️
sync-service63.17% <ø> (+0.19%)⬆️
typescript87.32% <85.71%> (+0.25%)⬆️
unit-tests67.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

pkg-pr-newBot commented Nov 19, 2025

Copy link
Copy Markdown

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

Comment threadpackages/typescript-client/src/client.ts Outdated
@samwillis
samwillis merged commit aacfba4 into mainNov 19, 2025
57 of 58 checks passed
@samwillis
samwillis deleted the samwillis/expose-fetch-snapshot branch November 19, 2025 14:29
Sign up for freeto 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

@samwillis@kevin-dp