Cloud code retries, error handling question
-
Scenario:
Lets say a user needs to consume 1 item to upgrade another. Its a perfect task for cloud code to prevent exploits. Lets say both items are each a user entity or custom entity (doesn't matter which).In the cloud script, if we get item 1 (material item) and delete it, and then get item 2 (item to upgrade) and attempt to enhance it, but the first call (delete) works and the second call (upgrade) fails (maybe network failure or something), wouldn't this result in a scenario where the user lost their item without getting the upgrade?
Perhaps the only solution to this is to make the users items one large entity, broken up into multiple items, so that the cloud script can either fail and no item gets consumed, or succeed and edit the larger "items" which does both delete the item and upgrade the other in the same call?
-
A good way to handle failure besides retrying in code, is to schedule another script to run 1 minute later that will basically repeat the same action.