Marks getCustomers refetches forever when the list is legitimately empty #1065

Closed
opened 2026-08-13 06:02:47 +00:00 by spikerj · 1 comment
Owner

getCustomers() short-circuits to the in-memory resource only when cached.length > 0. A successfully loaded empty list ([]) takes the reload branch on every subsequent call, so a shop with zero customers (or a first sync that returned empty) hits /api/mark-wilson/customer again each time the UI asks.

hasValue() is already true; the length check treats "empty but settled" as "failed/unloaded". Use hasValue() (or a distinct uninitialized state) so a real empty list is served from memory like a non-empty one.

Repro: flush GET .../customer with [], call getCustomers() again — a second GET is issued.

Seen in projects/spikersoft/src/app/_services/marks-site/marks-customer/marks-customer.service.ts.

`getCustomers()` short-circuits to the in-memory resource only when `cached.length > 0`. A successfully loaded empty list (`[]`) takes the reload branch on every subsequent call, so a shop with zero customers (or a first sync that returned empty) hits `/api/mark-wilson/customer` again each time the UI asks. `hasValue()` is already true; the length check treats "empty but settled" as "failed/unloaded". Use `hasValue()` (or a distinct uninitialized state) so a real empty list is served from memory like a non-empty one. Repro: flush `GET .../customer` with `[]`, call `getCustomers()` again — a second GET is issued. Seen in `projects/spikersoft/src/app/_services/marks-site/marks-customer/marks-customer.service.ts`.
Author
Owner

Resolved in spikersoft-angular PR #819 (merged to master). Marks getCustomers does not refetch forever when the list is legitimately empty. Closing.

Resolved in spikersoft-angular [PR #819](https://git.spikersoft.com/spikerj/spikersoft-angular/pulls/819) (merged to `master`). Marks getCustomers does not refetch forever when the list is legitimately empty. Closing.
Sign in to join this conversation.