The Purchase Order form never reached the server. Creating a PO with two
or more "Manual Entry" rows fired N parallel POSTs to
/api/collections/stock_items/records via Promise.all. The PocketBase JS
SDK auto-cancels any in-flight request whose method + path match a newer
one, so the first POST was aborted with:
ClientResponseError 0: The request was autocancelled.
Promise.all then rejected before the PO create ever ran, so the PO was
never created - only an orphan stock item per attempt. Confirmed against
the production PB logs: two stock_items POSTs today, zero
purchase_orders POSTs, and two orphan stock_items rows with no PO.
Fixes:
- src/lib/pocketbase.ts: pb.autoCancellation(false) on the browser
client. Every server-side client in this repo already did this
(scripts/*.mjs, server/po-api.mjs) - the browser client was the one
place it was missing.
- PurchaseOrderForm: resolve rows sequentially instead of Promise.all,
and build the snapshot in the same pass so manual rows carry the real
stock item id instead of "".
- PurchaseOrderForm: disable the submit button while submitting, so a
double click cannot create two POs.
- PurchaseOrderForm: compare SKUs trimmed, so a stray trailing space
does not create a duplicate stock item.
- po-photo-ingest.mjs, jei_skill.ts, setup-users.js: same
autoCancellation(false) guard.