ListStorageObjectsAsync with cursor to list all objects. Possible api spam?

Do you see any issues with the following code possibly spamming the API infinitely?

public async Task<ApiGameplayItem[]> GetGameplayItemsAsync(ISession session, CancellationToken canceller = default)
{
    List<ApiGameplayItem> items = new();

    string cursor = null;
    while (true)
    {
        IApiStorageObjectList itemObjs = await _client.ListStorageObjectsAsync(session, "econ_gameplay_items", limit: 100, cursor);

        foreach (IApiStorageObject obj in itemObjs.Objects)
        {
            try
            {
                items.Add(obj.Value.FromJson<ApiGameplayItem>());
            }
            catch (Exception e)
            {
                Log.Error(LogChannel.API, $"{nameof(GetGameplayItemsAsync)}: Failed to parse ApiGameplayItem", e, new Dictionary<string, object> {
                    { "itemID", obj.Key }
                });
            }
        }

        if (itemObjs.Cursor == null)
            break;

        cursor = itemObjs.Cursor;
    }

    return items.ToArray();
}

We’re seeing some weirly spiky high loads that seem quite random. I have a hunch it’s this but can’t see what might be wrong here.

Just to get an idea of the implemented game logic, how many items does a player have in average?

Under what circumstances is the item retrieval request getting fired? On any repeatable user interaction?

Doesn’t seem like there’s anything wrong with this snippet, tho I’m completely new to this stack, so don’t rely on my expertise.

Hello @wbronchart,

The snippet looks correct and we’re not aware of any issues with the listing API that could cause it to not paginate correctly.

I confirmed all is working as intended, thanks!