[w3c/IndexedDB] `retrieve multiple items from an index` index out of bounds error (Issue #480)

stelar7 created an issue (w3c/IndexedDB#480)

When running [retrieve multiple items from an index](https://w3c.github.io/IndexedDB/#retrieve-multiple-items-from-an-index) with the `nextunique` or `prevunique` direction, we iterate over items in a while loop.

3. Let i be 0.
4. While i is less than rangeRecordsLength, then:
 1. Increase i by 1.
 2. if record’s [size](https://infra.spec.whatwg.org/#list-size) is equal to count, then [break](https://infra.spec.whatwg.org/#iteration-break).
 3. If the result of [comparing two keys](https://w3c.github.io/IndexedDB/#compare-two-keys) using the keys from |rangeRecords[i]| and |rangeRecords[i-1]| is equal, then [continue](https://infra.spec.whatwg.org/#iteration-continue).
 4. Else [append](https://infra.spec.whatwg.org/#list-append) |rangeRecords[i]| to records.

This means
* `range_records[0]` will never be added to `records`.
 * We always start with `i = 1`
* In the last iteration, we will try to access `range_records[length]`, and that is out of bounds.
 * We check for `less than`, then increment it to be equal

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/IndexedDB/issues/480
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/IndexedDB/issues/480@github.com>

Received on Tuesday, 28 October 2025 09:40:50 UTC