fix(plugins): yield to a macrotask between vault snapshot chunks#190
Open
rotecodefraktion wants to merge 1 commit into
Open
fix(plugins): yield to a macrotask between vault snapshot chunks#190rotecodefraktion wants to merge 1 commit into
rotecodefraktion wants to merge 1 commit into
Conversation
streamVaultSnapshot yielded with queueMicrotask, which drains before any render — the whole chunk loop ran as one blocking task on the host main thread. Use the existing yieldToMain() helper (scheduler.postTask / 0ms timeout) so the UI can repaint between chunks. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
d1854e2 to
6ead2bb
Compare
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
streamVaultSnapshotyielded between chunks withqueueMicrotask. Themicrotask queue drains before the browser gets a chance to paint, so the
entire chunk loop effectively ran as a single blocking task on the host
main thread. Switched to the existing
yieldToMain()helper(
scheduler.postTaskwith a0ms-timeout fallback) — a real macrotaskboundary — so the UI can repaint between chunks.
Why
On large vaults the snapshot stream froze the host UI until the loop
finished. Yielding to a macrotask keeps the app responsive while the
snapshot streams to plugins.
How it was tested
npm run lintnpm run typecheck(no errors introduced by this change)npm test—vaultSnapshotCache,syncPullWritesSnapshot,largeVaultPerfpassnpm run buildNotes
Single-file change (
src/plugins/vaultSnapshot.ts, +7/-4). Reuses thealready-present
yieldToMain()from@/utils/bootTrace.