Describe the bug
Live collections are supposed to indicate when they have errored as shown in https://tanstack.com/db/latest/docs/guides/error-handling#collection-status-and-error-states
But when queryFn throws errors the collection is marked as ready and no error status is activated.
To Reproduce
Simply throw an error from the query function and observe the isError() signal of the live collection.
@Injectable({
providedIn: 'root',
})
export class Transtackdb {
queryClient = inject(QueryClient);
todoCollection = createCollection(
queryCollectionOptions({
queryKey: ['todos'],
queryClient: this.queryClient,
queryFn: async (): Promise<Todo[]> => {
throw new Error('Failed to fetch todos');
},
getKey: (item) => item.id,
}),
);
}
@Component({
selector: 'app-tanstackdb',
template: `
<div>Status: {{ query.status() }}</div>
<div>Loading: {{ query.isLoading() }}</div>
<div>Ready: {{ query.isReady() }}</div>
<div>Error: {{ query.isError() }}</div>
<div>Total: {{ query.data().length }}</div>
<ul>
@for (todo of query.data(); track todo.id) {
<li>
{{ todo.text }}
</li>
}
</ul>
`,
})
export class Tanstackdb {
tanstackDb = inject(Transtackdb);
query = injectLiveQuery((q) =>
q.from({ todo: this.tanstackDb.todoCollection }).where(({ todo }) => eq(todo.completed, false)),
);
}
This displays:
Status: ready
Loading: false
Ready: true
Error: false
Total: 0
Expected behavior
Expected error to be true.
Desktop (please complete the following information):
- OS: Mac
- Browser Chrome
"@tanstack/angular-db": "0.1.52",
Describe the bug
Live collections are supposed to indicate when they have errored as shown in https://tanstack.com/db/latest/docs/guides/error-handling#collection-status-and-error-states
But when queryFn throws errors the collection is marked as ready and no error status is activated.
To Reproduce
Simply throw an error from the query function and observe the isError() signal of the live collection.
This displays:
Status: ready
Loading: false
Ready: true
Error: false
Total: 0
Expected behavior
Expected error to be true.
Desktop (please complete the following information):
"@tanstack/angular-db": "0.1.52",