You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cloudflare-r2-binding: getKeys and clear ignore objects beyond the first 1000 #880
unstorage 2.0.0-beta.0 (also reproducible on main)
Cloudflare Pages / Workers with an R2 binding
Reproduction
awaitPromise.all(Array.from({length: 1005},(_,i)=>storage.setItem(`many:${i}`,"x")));console.log((awaitstorage.getKeys("many")).length);// 1000 instead of 1005
Calling the driver's clear("many:") with these 1005 keys leaves all of them in the bucket.
Describe the bug
The cloudflare-r2-binding driver silently ignores every object beyond the first 1000 :
getKeys calls R2Bucket.list() only once. R2 returns at most 1000 objects per call and signals the rest with truncated / cursor, which the driver does not follow. Any listing therefore stops at 1000 keys, and so does everything that relies on it (snapshot, the getKeys + removeItem fallbacks, ...).
clear passes all the listed keys to a single R2Bucket.delete(keys) call. R2 accepts at most 1000 keys per bulk delete, so with more keys nothing is deleted.
For comparison, cloudflare-kv-binding already follows the cursor in getKeys.
Additional context
I'm currently working around it with a pnpm patch generated by Claude that does the following in getKeys :
Activity