PinataCloud / Pinata-SDK

Official SDK for the Pinata IPFS service
MIT License
273 stars 67 forks source link

`getFilesByCount` output cut short if `maxCount == -1` #166

Closed yvt closed 5 months ago

yvt commented 8 months ago

The getFilesByCount method returns fewer rows if the actual count is not a multiple of the page limit (10).

When a fetched paginated result contains less than pageLimit, keepLooping is set to false here:

https://github.com/PinataCloud/Pinata-SDK/blob/949a2f99330318975cbb7c61c35a0253ba5f339b/src/commands/data/getFilesByCount/getFilesByCount.ts#L34-L37

...which causes next() to resolve with { done: true, ... }, terminating the async iterator:

https://github.com/PinataCloud/Pinata-SDK/blob/949a2f99330318975cbb7c61c35a0253ba5f339b/src/commands/data/getFilesByCount/getFilesByCount.ts#L45-L54

In this case, the returned value is treated as a generator return value, which is just thrown away by a for await...of loop. (A for await...of loop only iterates over yielded values.)

stevedylandev commented 5 months ago

Hey there! Thank you for this feedback! We are currently rewriting the SDK and will take this into consideration