Skip to content

fix: include skipQueue tasks in queueSize getter (backport to v5)#1042

Open
algojogacor wants to merge 3 commits into
piscinajs:v5from
algojogacor:fix/queueSize-skipQueue
Open

fix: include skipQueue tasks in queueSize getter (backport to v5)#1042
algojogacor wants to merge 3 commits into
piscinajs:v5from
algojogacor:fix/queueSize-skipQueue

Conversation

@algojogacor

Copy link
Copy Markdown

This is an independent contribution and is not associated with any hackathon or competition.

Summary

Backport the queueSize fix from the current branch to v5. The queueSize getter now accounts for tasks in skipQueue that were submitted with an AbortSignal.

Root Cause

When tasks are submitted with an AbortSignal and cannot be scheduled immediately, they are placed in the skipQueue (line 468 of src/index.ts) instead of the taskQueue. However, the queueSize getter only counted taskQueue.size, ignoring tasks waiting in skipQueue. This caused pool.queueSize to report 0 even when tasks were queued.

Fix

Added + pool.skipQueue.length to the queueSize getter calculation:

- return Math.max(pool.taskQueue.size - pool.pendingCapacity(), 0);
+ return Math.max((pool.taskQueue.size + pool.skipQueue.length) - pool.pendingCapacity(), 0);

This is a backport of the fix already present on the current branch.

Testing

  • The existing skipQueue integration already drains during _maybeDrain() — the getter now reflects its contents.
  • No behavioral regression: the returned value only increases (or stays the same) since we added, never subtracted.

Closes #1029

Signed-off-by: Arya Rizky <arya.rizky@example.com>

@metcoder95 metcoder95 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a test for it?

@metcoder95 metcoder95 added the backport v6 PR to backport to v6 label May 25, 2026
@metcoder95 metcoder95 removed the backport v6 PR to backport to v6 label Jun 4, 2026
@metcoder95 metcoder95 enabled auto-merge (squash) June 4, 2026 08:56
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

This issue has been marked as stale because it has been opened 45 days without activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the stale label Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants