Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit f36b49b

Browse files
committed
Gate Durable Object list() startAfter splice()
This isn't actually a problem, but if `keyNames` was empty and `startAfter` was `undefined`, we were `splice`ing on an empty array with a non-zero delete count.
1 parent 8915db5 commit f36b49b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/durable-objects/src/storage.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,14 @@ async function list<Value = unknown>(
196196
const { keys } = await storage.list(options);
197197
let keyNames = keys.map(({ name }) => name);
198198

199-
if (keyNames[0] === options.startAfter) {
200-
// If the first key matched `startAfter`, remove it as this is exclusive.
201-
keyNames.splice(0, 1);
202-
} else if (originalLimit !== undefined) {
203-
// Otherwise, make sure the original `limit` still holds.
204-
keyNames = keyNames.slice(0, originalLimit);
199+
if (options.startAfter !== undefined) {
200+
if (keyNames[0] === options.startAfter) {
201+
// If the first key matched `startAfter`, remove it as this is exclusive.
202+
keyNames.splice(0, 1);
203+
} else if (originalLimit !== undefined) {
204+
// Otherwise, make sure the original `limit` still holds.
205+
keyNames = keyNames.slice(0, originalLimit);
206+
}
205207
}
206208

207209
return get(

0 commit comments

Comments
 (0)