question

andrestallos avatar image
andrestallos asked

Duplicate Cloudscript calls

Hello! We've been having a recurrent problem with Cloudscript calls since we started using it a few years back, so I thought it's about time I ask about this!

In a small fraction of cases, a Cloudscript call (made with ExecuteCloudScript through the Unity SDK) gets triggered twice. It seems to happen at random - we haven't been able to reproduce it, or to find any pattern in terms of handlers, devices, etc. A player will report an error, and when we look at the Event History, we see that the handler has been called twice almost simultaneously (with a difference below half a second). The second call will normally fail, as it should, sometimes with ConcurrentEdit errors, other times because the first call has already modified some data and the second is no longer valid. Unfortunately, that second call will often return its result first, while the first one is still running, so the client will show an error to the user, even when the operation has been completed successfully by the first call and the result arrives an instant later. It may only happen about once every 10k calls, but it still adds up to multiple cases every day.

We are pretty certain that our code isn't generating the duplicate calls, though if no one else has experienced a similar problem I guess we'd have to take another look. Since Cloudscript is stateless, and the calls happen so close to each other, we haven't been able to come up with a way to detect and deal with these duplicate calls on the server side. We have added some client code to handle these errors in the most important handlers, but it's fairly custom for each call so it's very inefficient to do it for all handlers and scenarios.

You can check a recent case in titleId AE2C, playerId 598BDB67A6CD70AF, eventIds:

2fc6f0938e9647f3bad4499238edf67b (at 2018-11-05T11:37:21.037183Z)

c2a931b38e5e4d16b7ccc4cf253885fe (at 2018-11-05T11:37:21.294064Z)

Is this something you have seen before? Is there any recommended pattern for dealing with it?

We are using version 180213 of the Unity SDK (which I know is fairly out of date, but I haven't seen anything related to this error on the release notes) and , though as

Thank you in advance!

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
JayZuo avatar image
JayZuo answered

I didn't see this behavior before. Could this because the player perform ExecuteCloudScript twice? For example, the ExecuteCloudScript method is called by a button click event and the player may double click the button quickly. Thus, you will see duplicate Cloudscript calls in Event History.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

andrestallos avatar image andrestallos commented ·

Thanks for the answer. We'll review the code to check if that may be the case. We try to block player input while processing these calls, but there might be some issue with the way we do it. Thanks!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.