MONEI / Shopify-api-node

Node Shopify connector sponsored by MONEI
https://monei.com/shopify-payment-gateway/
MIT License
945 stars 278 forks source link

Ensure that body extensions aren't inspected unless the body is an array #548

Closed airhorns closed 2 years ago

airhorns commented 2 years ago

Fixes #547. During the code review of the retries PR, we ended up unifying the REST and GraphQL error handling logic, and also dropping the defensive bits that ensured the format of the errors object was checked before doing properties access. This restores the defensive checks since this code now needs to touch errors from the REST API which come in all sorts of shapes.

coveralls commented 2 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling af13f5b7692d08c49ac27d4350d19ac96b37a984 on gadget-inc:422-retries into 49a52f778529632887e717848fe4214ac2d97cc6 on MONEI:master.

lpinca commented 2 years ago

I'm not sure I understand. calculateDelay should not be called if the status code is 422, no?

lpinca commented 2 years ago

Ok, it seems that got skips the retry if the backoff value is 0 https://github.com/sindresorhus/got/blob/v11.8.5/source/core/index.ts#L2582-L2605 which is what retryObject.computedValue holds when the status code is 422.

lpinca commented 2 years ago

Thank you.