docs: Add investigation of ElectricSQL freeze after shape handle expiration#1194
Draft
KyleAMathews wants to merge 3 commits intomainfrom
Draft
docs: Add investigation of ElectricSQL freeze after shape handle expiration#1194KyleAMathews wants to merge 3 commits intomainfrom
KyleAMathews wants to merge 3 commits intomainfrom
Conversation
…ent row
Root cause is a two-layer problem:
1. ElectricSQL Cloud serves stale Cloudflare-cached snapshot after handle expiration
2. state.ts applies Object.assign({}, undefined, partialData) creating incomplete row
The incomplete row (only 5 of ~20 fields) enters the collection and BTree index,
causing the maybeRunGraph while(pendingWork()) loop to not converge properly during
lazy loading for ORDER BY + LIMIT queries.
Documented root cause, code flow analysis, and four recommended fixes.
https://claude.ai/code/session_01MbYMCjmyKh3MdebLHd2ytq
The original notes show NO 409 response. The old handle was already marked expired in ExpiredShapesCache (from a prior session). The expired_handle param is a cache buster but Cloudflare still served stale data (cf-cache-status: HIT, age: 663). This may be related to the stale cache offset bug in electric-sql/electric#3785 where stale responses cause mismatched handle/offset state. https://claude.ai/code/session_01MbYMCjmyKh3MdebLHd2ytq
|
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
Contributor
|
Size Change: 0 B Total Size: 90.9 kB ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 3.7 kB ℹ️ View Unchanged
|
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.
🎯 Changes
This PR adds a comprehensive investigation document (
INVESTIGATION-electricsql-freeze.md) that details a critical issue where the application freezes when navigating back to a meeting page after an ElectricSQL shape handle has expired.Problem Summary
The freeze occurs due to a two-layer problem:
ElectricSQL Cloud Stale Cache: When a shape handle expires and reconnects, the initial snapshot may be served from Cloudflare cache (up to 11 minutes stale), missing rows that were created/modified after caching.
TanStack/db Partial Update Without Guard: The
state.tscollection handler applies partial UPDATEs viaObject.assign({}, undefined, partialData)when a row doesn't exist in the current sync session, creating an incomplete row object with only 5 of ~20 expected fields.Root Cause Chain
undefinedstart_timefield (nulls-first ordering)null→false)requestLimitedSnapshot→index.take()must traverse past this entrymaybeRunGraphloop'swhile (pendingWork())repeatedly triggers BTree traversalsInvestigation Includes
cf-cache-status: HIT,age: 663)state.ts(primary fix)maybeRunGraphloop✅ Checklist
🚀 Release Impact
This investigation document serves as a reference for implementing the recommended fixes and understanding the interaction between ElectricSQL's shape caching, partial updates, and TanStack/db's query execution pipeline.
https://claude.ai/code/session_01MbYMCjmyKh3MdebLHd2ytq