Skip to content

feat(sync-service): Re-enable pluggable snapshot function - #3444

Merged
magnetised merged 1 commit into
mainfrom
magnetised/pluggable-snapshot-function
Nov 19, 2025
Merged

magnetised merged 1 commit into
mainfrom
magnetised/pluggable-snapshot-function

Conversation

@magnetised

Copy link
Copy Markdown
Contributor

Phoenix.Sync relies on patching the snapshot function in its sandbox repo feature (where it uses an Ecto.Repo instance to get a pool connection and returns fake xids). When we removed dependency injection we broke this, so this PR just adds back in the ability to inject a custom stream_snapshot_from_db/5 function.

I also removed the requirement to pass seed_config to the stack config instance by adding in defaults for most of the required values and removed the unused shape_changes_registry value from the stack config. We have defaults for these values so we should use them. Generally if we add config we should have a default -- it makes Phoenix.Sync less likely to break with every addition.

In DynamicConsumerSupervisor I noticed a potential problem where the DynamicSupervisor spec passed to PartitionSupervisor could have a name which would cause problems.

@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2025 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: b6ecba1

@codecov

codecov Bot commented Nov 17, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.00000% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.59%. Comparing base (c44e801) to head (b6ecba1).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
...ervice/lib/electric/shapes/consumer/snapshotter.ex 0.00% 11 Missing ⚠️
...lib/electric/shapes/dynamic_consumer_supervisor.ex 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3444      +/-   ##
==========================================
+ Coverage   67.55%   67.59%   +0.04%     
==========================================
  Files         180      180              
  Lines        9672     9675       +3     
  Branches      359      360       +1     
==========================================
+ Hits         6534     6540       +6     
+ Misses       3136     3133       -3     
  Partials        2        2              
Flag Coverage Δ
elixir 64.19% <20.00%> (+0.04%) ⬆️
elixir-client 74.47% <ø> (+0.52%) ⬆️
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/typescript-client 93.57% <ø> (ø)
packages/y-electric 55.12% <ø> (ø)
postgres-140000 62.86% <20.00%> (+0.01%) ⬆️
postgres-150000 62.90% <20.00%> (+0.12%) ⬆️
postgres-170000 62.89% <20.00%> (+0.17%) ⬆️
postgres-180000 62.91% <20.00%> (-0.02%) ⬇️
sync-service 63.16% <20.00%> (+<0.01%) ⬆️
typescript 87.06% <ø> (ø)
unit-tests 67.59% <20.00%> (+0.04%) ⬆️

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.

@magnetised
magnetised force-pushed the magnetised/pluggable-snapshot-function branch from aa390a0 to 213d82d Compare November 18, 2025 10:13
@magnetised
magnetised marked this pull request as ready for review November 18, 2025 10:29
Phoenix.Sync relies on patching the snapshot function in its sandbox
repo feature (where it uses an Ecto.Repo instance to get a pool
connection and returns fake xids). When we removed dependency injection
we broke this, so this PR just adds back in the ability to inject a
custom stream_snapshot_from_db/5 function.

I also removed the requirement to pass seed_config to the stack config
instance by adding in defaults for most of the required values and
removed the unused `shape_changes_registry` value from the stack config.
We have defaults for these values so we should use them. Generally if we
add config we should have a default -- it makes Phoenix.Sync less likely
to break with every addition.

In DynamicConsumerSupervisor I noticed a potential problem where the
DynamicSupervisor spec passed to PartitionSupervisor could have a `name`
which would cause problems.
@magnetised
magnetised force-pushed the magnetised/pluggable-snapshot-function branch from 213d82d to b6ecba1 Compare November 19, 2025 09:19
@magnetised
magnetised merged commit 1e51dd3 into main Nov 19, 2025
50 of 51 checks passed
@magnetised
magnetised deleted the magnetised/pluggable-snapshot-function branch November 19, 2025 14:51
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.

2 participants