Conversation
🦋 Changeset detectedLatest commit: 581ada6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-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: |
|
Size Change: +79 B (+0.11%) Total Size: 74.1 kB
ℹ️ View Unchanged
|
| // Ensure listeners are active before emitting this critical batch | ||
| if (this.lifecycle.status !== `ready`) { | ||
| this.lifecycle.setStatus(`ready`) | ||
| this.lifecycle.markReady() |
There was a problem hiding this comment.
This change fixed what the real cause of the stuck loading status bug from #532. We should always use markReady when transitioning to ready.
There was a problem hiding this comment.
Maybe we just remove setStatus? It's nice to have proper functions where we can put in more logic when needed.
There was a problem hiding this comment.
not needed for this PR of course but a thought
| if (newStatus === `ready` && !allowReady) { | ||
| throw new CollectionStateError( | ||
| `Cannot set status to anything other than ready, must use markReady instead` | ||
| ) | ||
| } |
There was a problem hiding this comment.
I added this check to ensure we don't make the same mistake again when transitioning to ready - see other comment below.
|
Size Change: 0 B Total Size: 1.44 kB ℹ️ View Unchanged
|
| // Notify dependents when markReady is called, after status is set | ||
| // This ensures live queries get notified when their dependencies become ready | ||
| if (this.changes.changeSubscriptions.size > 0) { | ||
| this.changes.emitEmptyReadyEvent() | ||
| } |
There was a problem hiding this comment.
Moving this inside the if above ensures we only send this empty change event when we first transition to ready. This is the fix to prevent additional renders.
| public setStatus( | ||
| newStatus: CollectionStatus, | ||
| allowReady: boolean = false | ||
| ): void { |
There was a problem hiding this comment.
We should prevent same status calls: if (newStatus === this.status) return
There was a problem hiding this comment.
I would like to address this in a follow-up pr, when this is done it triggers at least one test failure.
.changeset/polite-eels-laugh.md
Outdated
| "@tanstack/db": patch | ||
| --- | ||
|
|
||
| Fix repeated renders when markReady called when the collection was already ready. This would occur after each long poll on a Electric collection. |
There was a problem hiding this comment.
| Fix repeated renders when markReady called when the collection was already ready. This would occur after each long poll on a Electric collection. | |
| Fix repeated renders when markReady called when the collection was already ready. This would occur after each long poll on an Electric collection. |
This fixes #597
We were emitting an empty change event whenever
markReadywas called, which would happed after each Electric long polling request returned.The code that triggers these additional empty events was added in #532 to fix a suck loading state. That PR introduced a test case that failed without this previous change. My change here initially caused a regression, but I went digging and found the real case of the stuck loading state and have fixed that 🥳