openwallet-foundation / askar

Secure storage designed for Hyperledger Aries agents.
Apache License 2.0
63 stars 51 forks source link

fix(js): scan fetch record limit #137

Closed genaris closed 1 year ago

genaris commented 1 year ago

There is an unnecessary chunk variable (inherited from previous Indy SDK implementation in AFJ) that is preventing fetchAll to retrieve all records when they are more than PAGE_SIZE. As a result, a given Scan cannot return more than 32 entries.

Simply checking for listHandle (scanNext return value) validity seems to be enough to determine if there are no more matching records.

genaris commented 1 year ago

Isn't the 256 here to prevent you from retrieving too many records and messing stuff up? Or do you we want to make that a responsiblity of the caller?

I think in this case is a bit different from Indy SDK because scanNext does not receive a chunk size: instead, it is retrieving at most 32 records per call (in Indy we used fetchWalletSearchNextRecords, which received a count parameter). So the loop will be executed until specified limit is reached or a scanNext call returns 0 records.