sphere-node-sdk icon indicating copy to clipboard operation
sphere-node-sdk copied to clipboard

Should retry on concurrent modification error

Open butenkor opened this issue 9 years ago • 3 comments

Expected behavior

If i update product and concurrent modification exception is thrown by API, SDK should use new version from API error response and retry payload. This behaviour should be configurable (i.e.: on client instantiation. Nice to have: per endpoint). More details on error: http://dev.commercetools.com/http-api-errors.html#409-conflict

Actual behavior

It rejects with concurrent modification error from API

Steps to reproduce the behavior

Update product attribute and publish at the same time

butenkor avatar May 10 '16 09:05 butenkor

This can be solved by using the retry util from sphere-node-utils, it doesn't need to be in the sdk

emmenko avatar May 10 '16 11:05 emmenko

How this can be solved with sphere-node-utils? Can you provide an example? Also why would every user need to implement retry if it could be done easily by SDK? It is common for SDKs to provide such functionality: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/retry/RetryPolicy.java

https://packagist.org/packages/postmen/sdk-php#user-content-automatic-retry-on-retryable-error

butenkor avatar May 10 '16 12:05 butenkor

I forgot that the API now returns the current version in the error message. http://dev.commercetools.com/http-api-errors.html#409-conflict

It would be easier to implement then. It would be good if you can provide a PR ;)

emmenko avatar May 10 '16 12:05 emmenko