Skip to content

fix: correct off-by-one in getJobs default end index - #1030

Open
tsushanth wants to merge 1 commit into
bee-queue:masterfrom
tsushanth:fix/getjobs-lrange-off-by-one
Open

fix: correct off-by-one in getJobs default end index#1030
tsushanth wants to merge 1 commit into
bee-queue:masterfrom
tsushanth:fix/getjobs-lrange-off-by-one

Conversation

@tsushanth

Copy link
Copy Markdown

Problem

Queue#getJobs defaults to { start: 0, end: 100 } for list/sorted-set
queue types (waiting, active, delayed). Both Redis LRANGE and
ZRANGE use inclusive bounds, so this call:

lrange key 0 100

returns 101 elements (indices 0 through 100 inclusive), not 100.

This is inconsistent with the size: 100 default used for the set-based
queue types (failed, succeeded), where the intent is clearly to return
at most 100 jobs by default.

Fix

Change the default end from 100 to 99 so that a no-argument
getJobs('waiting') call returns at most 100 jobs, matching the behaviour
of getJobs('failed') and the documented intent.

Callers who pass an explicit page.end are unaffected.

Redis LRANGE and ZRANGE use inclusive bounds, so lrange(key, 0, 100)
returns 101 elements. The default `end: 100` was inconsistent with the
`size: 100` default used for set-based queue types (failed/succeeded).

Change the default to `end: 99` so that a no-argument getJobs() call
returns at most 100 jobs for all queue types, matching the documented
intent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants