Test/progressive nested fastpath bug#1532
Draft
ibirrer wants to merge 2 commits into
Draft
Conversation
The e2e tests hung indefinitely in beforeAll on Node 24. The jsdom test environment provides its own AbortController/AbortSignal, but fetch is Node's native undici fetch. The Electric ShapeStream creates an AbortController (jsdom) and passes its signal to fetch (undici); Node 24's undici strictly rejects the foreign signal with a TypeError. The Electric client's backoff wrapper treats that error as retryable and retries forever, so preload() never resolves and beforeAll times out. The e2e tests exercise Postgres + Electric data sync and use no DOM APIs, so switch the environment to `node`, where AbortController and fetch are both Node-native and compatible. CI did not catch this because it pins Node 20, whose undici accepted the jsdom signal via a looser duck-typed check.
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…are static In `progressive` sync mode an Electric collection serves a fast-path snapshot for any loadSubset that arrives before its first `up-to-date` message, then loads the rest in the background. A collection queried directly got this fast path; the same collection fetched as a nested `toArray` child — or joined to a filtered parent — did not. Its rows only appeared once the entire child collection finished syncing. Root cause is ordering. Includes and joins lazy-load the child/joined collection by tapping the parent pipeline and issuing the child loadSubset only once the parent has produced rows. That deferred call resolves after the child's full background sync has completed, so its snapshot is discarded as stale and the query never sees the intermediate fast-path result. Fix: when the parent query statically constrains the correlation/join field to known keys (e.g. `.where(eq(parent.id, 5))`), push an equality predicate onto the child so it loads its subset eagerly — in parallel with the parent — through the normal subscription path, instead of via the deferred tap. When the keys are not statically known the existing lazy-loading behaviour is kept. - extractEqualityKeys() in expression-helpers.ts reads a fixed key set from a WHERE expression (eq / in, possibly nested in and). - compiler/index.ts applies it to `toArray` includes children. - compiler/joins.ts applies it to inner/left join sources (the only join types where filtering the joined side is sound). Tests: - packages/db/tests/query/progressive-includes-fastpath.test.ts Deterministic unit test: the nested child loadSubset now runs eagerly, inside the fast-path window, even while the parent collection is unsynced. - packages/electric-db-collection/e2e/progressive-nested.e2e.test.ts End-to-end against a real Electric server: the direct query, the nested toArray query and the nested join query all surface their 40-row target subset after only 40/4540 rows have loaded.
96a33e4 to
43d0237
Compare
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
✅ Checklist
pnpm test.🚀 Release Impact