-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: zrange rev flag causes empty return list / flaky zrange #742
Comments
benheckmann
changed the title
zrange works unpredictably
bug: zrange rev flag causes empty return list / flaky zrange
Aug 25, 2024
Update: I have done some more tests and find that the Here are some examples of what the cli returns vs what the node sdk returns. CLI:
Node: const key1 = "user:chat:1"
const key2 = "user:chat:29d2f72f-46a9-4137-9198-436f3194f64c"
const chats1: string[] = await kv.zrange(key1, 0, -1, { rev: true }) // returns Array(0) >> but should be returning Array(12)
const chats2: string[] = await kv.zrange(key2, 0, -1, { rev: true }) // returns Array(4)
const chats1NoRev: string[] = await kv.zrange(key1, 0, -1) // returns Array(12)
const chats2NoRev: string[] = await kv.zrange(key2, 0, -1) // returns Array(4)
const keyExists = await kv.exists(key1) // returns 1
const keyType = await kv.type(key1) // returns zset
const setSize = await kv.zcard(key1) // returns 12 For now, I will just omit the rev option and reverse the list myself. |
I have done some more tests and keep running into situations with unexpected behavior. For instance, const chats: string[] = await kv.zrange(`user:chat:${userId}`, 0, -1) sometimes returns an empty array, while const chats: string[] = await kv.zrange(`user:chat:${userId}`, 0, 3) is not empty. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
When using
kv.zrange
, the same input sometimes returns the list of values, and sometimes an empty list. When using the cli on Vercel, I always get the list.I have used the debugger to make sure that the userId is the same in both cases and it passes the authentication check. However,
chats
sometimes evaluates to an empty list, when it should have the values I get using the cli. This is right below the line, so its not that there is an error thrown.Not sure if this is an issue with the package or if I'm just unable to find out what the difference in the calls is when it works. In this case: is it possible to activate some sort of logging?
The text was updated successfully, but these errors were encountered: