writeUpsert / writeBatch path has no error propagation to useLiveQuery consumers #1468
Danny-Devs
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
The query-collection docs recommend
writeUpsert/writeBatchfor WebSocket-driven updates — "Direct writes bypass this system entirely and write directly to the synced data store, making them ideal for handling real-time updates from alternative sources."When the upstream fetch that feeds
writeUpsertfails, there's no way to propagate that error touseLiveQueryconsumers.QueryCollectionUtilsexposesisError,lastError,errorCount, andclearError()— but these only reflectqueryFnfailures flowing through the TQQueryObserver.writeUpsertbypasses the bridge entirely, so its failures are invisible to the collection's error lifecycle.The result: a failed WS-triggered fetch means
writeUpsertis never called, the collection doesn't know anything went wrong, anduseLiveQueryreturns no data and no error. The component shows a loading spinner indefinitely.Current workaround
We maintain a separate reactive error store outside TDB (
Map<entityId, { message, timestamp }>) and wire it into every composable manually. Each composable that reads from a WS-driven collection adds ~10 lines of boilerplate to read from both pipes (TDB for data, the error store for errors) and merge them:This works but scales linearly with the number of WS-driven entities — every composable repeats it.
Suggestion
An API like
collection.utils.reportError(key, error)that sets the collection into the same error state that aqueryFnfailure would — souseLiveQueryconsumers seeisError: truethrough the same channel. Or awriteError(key, error)alongsidewriteUpsert.Related
useLiveQuerycan't distinguish "loading" from "failed")Beta Was this translation helpful? Give feedback.
All reactions