Versions
@tanstack/db-sqlite-persistence-core@0.2.23 (latest published)
@tanstack/db@0.9.2
- Local-only
persistedCollectionOptions (no upstream sync adapter)
Bug
createLoopbackSyncConfig() starts runtime.ensureStarted() asynchronously and calls params.markReady() in both its fulfillment and rejection callbacks. Its cleanup() calls runtime.cleanup() but does not invalidate those already-registered callbacks.
A deterministic sequence is:
- Create a local-only persisted collection with an adapter whose initial SQLite hydration/read is held on a deferred Promise.
- Start
collection.preload().
- Call
collection.cleanup() while the startup read is pending.
- Settle the read, either by resolving it or rejecting it.
The late callback calls markReady() on the cleaned collection. In our account-switch/logout path this produces InvalidCollectionStatusTransitionError (cleaned-up -> ready) and an unhandled rejection. The rejection branch also logs a stale startup warning after the collection has been disposed.
The published dist/esm/persisted.js path is the same in current main: createLoopbackSyncConfig calls params.markReady() after ensureStarted().then(...) and in .catch(...), while cleanup only calls runtime.cleanup() / runtime.clearSyncControls().
Expected: Cleanup invalidates both startup continuations; neither calls markReady() or logs an obsolete startup error after cleanup. A new collection/session can then start independently.
Workaround: We carry a small package patch with a cleanedUp flag set before runtime cleanup, checked in both startup outcomes. Related app-side tracking: https://github.com/digitalcontour/oreol-monorepo/issues/299.
This is distinct from #1576 (preload after cleanup) and from the sync-present readiness policy in #1659. PR #1853 addresses several persistence lifecycle failures, but its current createLoopbackSyncConfig diff does not appear to fence the late markReady() callback; the regression above would be useful alongside it.
Versions
@tanstack/db-sqlite-persistence-core@0.2.23(latest published)@tanstack/db@0.9.2persistedCollectionOptions(no upstream sync adapter)Bug
createLoopbackSyncConfig()startsruntime.ensureStarted()asynchronously and callsparams.markReady()in both its fulfillment and rejection callbacks. Itscleanup()callsruntime.cleanup()but does not invalidate those already-registered callbacks.A deterministic sequence is:
collection.preload().collection.cleanup()while the startup read is pending.The late callback calls
markReady()on the cleaned collection. In our account-switch/logout path this producesInvalidCollectionStatusTransitionError(cleaned-up -> ready) and an unhandled rejection. The rejection branch also logs a stale startup warning after the collection has been disposed.The published
dist/esm/persisted.jspath is the same in currentmain:createLoopbackSyncConfigcallsparams.markReady()afterensureStarted().then(...)and in.catch(...), whilecleanuponly callsruntime.cleanup()/runtime.clearSyncControls().Expected: Cleanup invalidates both startup continuations; neither calls
markReady()or logs an obsolete startup error after cleanup. A new collection/session can then start independently.Workaround: We carry a small package patch with a
cleanedUpflag set before runtime cleanup, checked in both startup outcomes. Related app-side tracking: https://github.com/digitalcontour/oreol-monorepo/issues/299.This is distinct from #1576 (preload after cleanup) and from the sync-present readiness policy in #1659. PR #1853 addresses several persistence lifecycle failures, but its current
createLoopbackSyncConfigdiff does not appear to fence the latemarkReady()callback; the regression above would be useful alongside it.