Repository navigation
feat(Store): auto-heal stale price data stuck in cart - #1022
Conversation
|
Severity: Medium — server/api.js:1404: Removing The supplied commits have no merge base locally; review used their direct snapshot diff. |
There was a problem hiding this comment.
🟡 Changes recommended
A transient price-sync gap can delete a valid persisted cart line, while shipping failures omit reconciliation data and cart merging can overwrite fresh product details with stale data.
3 open issues
What changed in this PR
This PR adds cart reconciliation against the current Stripe catalog to repair stale prices before shipping and checkout.
Changes:
- Replace archived book prices with matching active variants, remove unavailable items, and merge matching cart lines.
- Apply reconciliation in the client, recalculate subtotals, and notify customers of price changes or removals.
- Add helper tests and require customers to review cart changes detected at checkout.
| File | Description |
|---|---|
| server/types/Store.ts | Defines the server reconciliation payload. |
| server/api/store.ts | Reconciles shipping requests and rejects stale checkout requests. |
| server/api/services/store-service.ts | Resolves replacement prices and merges reconciled items. |
| client/src/utils/storeHelpers.ts | Applies cart changes and formats customer notices. |
| client/src/utils/storeHelpers.test.ts | Tests reconciliation and notice helpers. |
| client/src/types/Store.ts | Defines client reconciliation and notice types. |
| client/src/screens/conductor/store/shipping.tsx | Applies server updates and displays cart notices. |
| client/src/providers/CartProvider.tsx | Updates cart state and recalculates subtotals. |
| client/src/context/CartContext.ts | Exposes the cart reconciliation action. |
| client/src/api.ts | Types reconciliation data in shipping responses. |
Review effort: Balanced
80943e1 to
47c015c
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The error path can change cart lines without clearing the previous shipping quote, leaving stale costs displayed and allowing payment to proceed without a valid quote for the updated cart.
1 open issue
3 resolved since last review
Review effort: Balanced
47c015c to
bc53eda
Compare
bc53eda to
e4cad8b
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Stripe mutations continue after lease ownership is lost, allowing stale runs to archive prices used by the new holder, while unbounded cart lookups risk exhausting shared Stripe limits.
3 open issues
1 resolved since last review
Review effort: Balanced
e4cad8b to
e95c2c2
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Critical lease-safety gaps allow renewal writes to shorten the stored expiry and release the lease before timed-out Stripe mutations are resolved, enabling overlapping syncs and incorrect price deactivation.
3 open issues
2 resolved since last review
Review effort: Balanced
| const sentAt = Date.now(); | ||
| StoreBookSyncLock.updateOne( | ||
| { _id: { $eq: bookID }, leaseID: { $eq: leaseID } }, | ||
| { $set: { lockedUntil: new Date(sentAt + BOOK_SYNC_LOCK_MS) } }, |
| } finally { | ||
| clearInterval(heartbeat); | ||
| // A failed release costs at most one lease length of waiting for the next run. | ||
| await StoreBookSyncLock.deleteOne({ _id: { $eq: bookID }, leaseID: { $eq: leaseID } }) |
|
🎉 This PR is included in version 2.157.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |


No description provided.