Cursor Pagination is always returning the same cursor

Hi,

I am calling the nkRuntime storageList using a cursor to return paginated data.

On the first call, the cursor is null and it returns the first page of data and the first cursor.
On the second call, I pass in the first cursor and it returns a second page but the cursor is the same as the first result, so the third call returns the second page again.

I have tried looping the calls to storageList and logging the cursor each time and it is always the same.

Here is my code. Is there something I have missed in implementing how the cursor is used?

UPDATE: On further investigation, I determined that when limit (numDocs) is null, the cursor returns correctly with the default 100 limit. If I pass in 100 or greater as the limit, it also works correctly. Using any number below 100 returns the same cursor on all requests.

public getDataList_Cursor = function(collection: string, nk: nkruntime.Nakama, numDocs: number, cursor?: string){

    this.logger.debug(`<<<<GETTING DATALIST>>>>`);

    if(cursor === ""){

        cursor = null;

    }

    const vgs = {};

    let vgResult: nkruntime.StorageObjectList = nk.storageList("00000000-0000-0000-0000-000000000000", collection, numDocs);

       

    vgResult.objects?.forEach((vgDoc) => {

        vgs[vgDoc.key] = vgDoc.value['count'];

    });

    // if there are more docs //

    let count: number = 0

    while (vgResult.cursor) {

        this.logger.info(vgResult.cursor);

        vgResult = nk.storageList("00000000-0000-0000-0000-000000000000", collection, numDocs, vgResult.cursor);

        if(vgResult.objects?.length > 0){

            vgResult.objects?.forEach((vgDoc) => {

                vgs[vgDoc.key] = vgDoc.value['count'];

            });

        }

        count++

        if(count === 10){

            this.logger.info("<<<<BREAKING>>>>")

            break;

        }

    }

Thanks for reporting this - tracking of this issue moved to github: Cursor Pagination is always returning the same cursor when limit is <100 · Issue #848 · heroiclabs/nakama · GitHub