question

Petter Vernersson avatar image
Petter Vernersson asked

InternalServerError GrantItemsToUser

Hi! I get an error when calling the function GrantItemsToUser from the server API in cloud code. This function has worked without problems in the past but has now starting to fail. I don't get a clear picture of what is wrong out of the error message.
When called from within the unity game engine I get a mention of Timeout but the script execution time is told to be 4 seconds, less than our limit on 10 seconds. I feel like the problem might have appeared when we added more items to the bundle that we are trying to grant to the user. The bundle contains quite a lot of items since this is an bundle that is granted to all of our users by default.

When running the cloud function in the playfab game manager we get this error response:

{
    "FunctionResult": null,
    "Logs": [
        {
            "Level": "Error",
            "Message": "PlayFab API request failure",
            "Data": [
                [
                    []
                ],
                [
                    [
                        [
                            [
                                []
                            ]
                        ],
                        [
                            []
                        ]
                    ]
                ],
                [
                    []
                ]
            ]
        }
    ],
    "ExecutionTimeSeconds": 4.0047093,
    "MemoryConsumedBytes": 34240,
    "APIRequestsIssued": 2,
    "HttpRequestsIssued": 0,
    "Error": {
        "Error": "InternalServerError",
        "Message": "InternalServerError",
        "StackTrace": "Error\n    at Object.server_request (Script:161:24)\n    at Object.server.GrantItemsToUser (Script:570:73)\n    at handlers.UpdateDefaultBundleVersion (B5E16-main.js:350:33)\n    at Object.invokeFunction (Script:116:33)"
    }
}

Anyone that has a clue of what might be tha cause, can a bundle be to big(contain to many items)?

The cloud code we run

server.GrantItemsToUser({
    ItemIds: ["DefaultBundleID"],
    PlayFabId: currentPlayerId
});
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.

Rick Chen avatar image
Rick Chen answered

I reproduced this issue by granting player with a bundle containing 160 items. I will submit a report to corresponding team.

If it is urgent, I suggest using container instead of bundle:

  1. Create a container that contains all the items in your bundle
  2. In your Cloud Script, grant the player with the container instead of the bundle (takes shorter time to execute)
  3. On Client side, the player can unlock the container with UnlockContainerInstance API.
10 |1200

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

Petter Vernersson avatar image
Petter Vernersson answered

Thanks for the detailed answer @Junjin Chen and sorry for my late response. I solved it with a workaround instead and just gave them the default items localy without ever granting them on the server. interesting with containers however, I did not know such a thing existed.

10 |1200

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

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.