Unhandled promise rejection when cart synchronization fails in o2m.ts
itsjab opened this issue · 0 comments
Current behavior
In o2m.ts, when synching the cart with Magento fails, the promise is not rejected. Simply put, the catch block is missing. The request is was never terminated until the client rejects with a 504.
Expected behavior
Promise rejection is handled in a catch block, returning a status code of 500 and error message back to the client
Steps to reproduce the issue
- Setup a default storefront API environment using the demo Magento
- Place an order with an invalid cart ID
In the api logs, you will see output similar to this:
`> Order Id undefined
Is order authorized? false
User Id
ORD:1 - > Cart Id 9fbef40d9055cafacef952016186a4de
ORD:1 - < Cart Id 9fbef40d9055cafacef952016186a4de
error: API call failed: No such entity with cartId = 720409
(node:259) UnhandledPromiseRejectionWarning: [object Object]
(node:259) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)`
Repository
Can you handle fixing this bug by yourself?
- YES
- NO
Environment details
I am using the SF API docker setup
- OS: Docker with Ubuntu 18.04
- Node: node:10-alpine3.11
- Code Version: 1.0.0-rc.3
Additional information
I am currently developing a checkout service for VSF, not sure if this error can occur when placing the order through VSF. Anyway, it is a simple fix and I am happy to submit a PR.