WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@KyleAMathews
Copy link
Contributor

Add async parsing methods that yield to the main thread periodically, preventing the UI from becoming unresponsive when syncing shapes with many rows.

  • Add yieldToMain() utility that uses scheduler.yield() when available, falling back to setTimeout(0)
  • Add parseAsync() and parseSnapshotDataAsync() methods to MessageParser that yield every 1000 messages by default
  • Update ShapeStream to always use async parsing for long-poll responses and snapshots
  • Export yieldToMain and DEFAULT_YIELD_EVERY for users who need custom yielding in their own processing code

…hapes

Add async parsing methods that yield to the main thread periodically,
preventing the UI from becoming unresponsive when syncing shapes with
many rows.

- Add yieldToMain() utility that uses scheduler.yield() when available,
  falling back to setTimeout(0)
- Add parseAsync() and parseSnapshotDataAsync() methods to MessageParser
  that yield every 1000 messages by default
- Update ShapeStream to always use async parsing for long-poll responses
  and snapshots
- Export yieldToMain and DEFAULT_YIELD_EVERY for users who need custom
  yielding in their own processing code
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.64%. Comparing base (0408955) to head (06b0482).
⚠️ Report is 3 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (0408955) and HEAD (06b0482). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (0408955) HEAD (06b0482)
unit-tests 6 5
typescript 4 3
packages/typescript-client 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3540       +/-   ##
===========================================
- Coverage   75.24%   61.64%   -13.61%     
===========================================
  Files          51       40       -11     
  Lines        2743     1559     -1184     
  Branches      404      106      -298     
===========================================
- Hits         2064      961     -1103     
+ Misses        677      597       -80     
+ Partials        2        1        -1     
Flag Coverage Δ
electric-telemetry 22.71% <ø> (-0.28%) ⬇️
elixir 57.38% <ø> (-0.09%) ⬇️
elixir-client 73.94% <ø> (ø)
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/typescript-client ?
packages/y-electric 55.12% <ø> (ø)
typescript 72.39% <ø> (-15.06%) ⬇️
unit-tests 61.64% <ø> (-13.61%) ⬇️

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 Dec 2, 2025

Open in StackBlitz

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

commit: 06b0482

- Remove flaky timing assertion in yield test that assumed specific
  setTimeout ordering
- Run prettier on modified files
- Add yield test for parseAsync to improve coverage (was only testing
  parseSnapshotDataAsync yields)
- Fix globalThis guard order in yieldToMain - move typeof check before
  assignment to avoid reference errors in exotic environments
Remove the yieldEvery parameter from parseAsync and parseSnapshotDataAsync
methods - yield interval is now fixed at 1000 messages internally. This
simplifies the API; configurability can be added later if users need it.

- Remove yieldEvery parameter from async parsing methods
- Remove DEFAULT_YIELD_EVERY from public exports
- Update tests to work with fixed yield interval
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