question

Kim Strasser avatar image
Kim Strasser asked

Cloud Script: The script execution was terminated after the maximum execution time limit

I got this error message because I waited to long in my cloud script function:

"Error": {
            "Error": "CloudScriptExecutionTimeLimitExceeded",
            "Message": "The script execution was terminated after the maximum execution time limit",
            "StackTrace": null
        }

In addition, I got this PlayStream event:

Raw event JSON
{
    "EventName": "title_exceeded_limit",
    "LimitId": "CloudScript:ScriptExecutionTime",
    "LimitDisplayName": "Processing time for a CloudScript function called by the ExecuteCloudScript API.",
    "Unit": "Seconds",
    "LimitValue": 4.5,
    "Value": 4.5137887,
    "AssociatedEntities": {
        "player": [
            "C30AD4505A3C3388"
        ]
    },
    "Details": {
        "Function": "UpdateLeaderboard"
    },
    "EventNamespace": "com.playfab",
    "EntityType": "title",
    "Source": "PlayFab",
    "EventId": "8bb1a51b12bc44eebc7045b81e8fce97",
    "EntityId": "BFD0A",
    "SourceType": "BackEnd",
    "Timestamp": "2020-01-05T18:20:21.7273474Z",
    "History": null,
    "CustomTags": null,
    "Reserved": null,
    "PlayFabEnvironment": {
        "Vertical": "master",
        "Cloud": "main",
        "Application": "logicserver",
        "Commit": "14dbbed"
    }
}

Is my maximum execution time limit 4.5 seconds(4500 milliseconds)?

Is it possible to get more execution time?

I want to create a waiting time(for example 1000 milliseconds) so that the client can not call server.UpdateUserReadOnlyData and server.UpdateUserInternalData very frequently.

Are 1000 milliseconds a reasonable waiting time?

I use this code to create the waiting time:

handlers.UpdateLeaderboard = function (args, context)
{
    var waitingtime = 600000; // just for testing the limit
    sleep(waitingtime);
    server.UpdateUserReadOnlyData
    ...
}

function sleep(milliseconds)
{
    const date = Date.now();
    let currentDate = null;
    do {
    currentDate = Date.now();
    } while (currentDate - date < milliseconds);
}
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

·
Seth Du avatar image
Seth Du answered

Yes, Cloud Script maximum execution time can be extended, but I don’t think you are using it the correct way. You shouldn’t add any wait sentences in Cloud Script because it is unnecessary. If you want to restrict updating frequency, simply adding wait sentences on the clients should solve it.

Another method is to navigate to the Limit page in Game Manger, enter the corresponding entry. You can customize the limit by reducing it:


2 comments
10 |1200

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

Kim Strasser avatar image Kim Strasser commented ·

What happens if a client tries to update Player data value more often than the custom limit update operations?

In this case it is 5 update operations. Will the client get an error message when he tries to update Player data value the sixth time during 15 seconds? Or what will happen?

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Kim Strasser commented ·

The data won't be updated and error will be returned in the callback.

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.