Skip to content

Commit

Permalink
fix: pass abort controller instead
Browse files Browse the repository at this point in the history
  • Loading branch information
dylandepass committed Feb 5, 2025
1 parent 894bb01 commit 468d46a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/helix-shared-process-queue/src/process-queue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ export default function processQueue<
* @property {number} maxConcurrent Maximum number of items processed concurrently
* @property {number} limit Maximum number of items processed within the interval
* @property {number} interval Time window in milliseconds
* @property {AbortSignal} abortSignal Optional abort signal
* @property {AbortController} abortController Optional abort controller
*/
export declare type RateLimitOptions = {
maxConcurrent: number;
limit: number;
interval: number;
abortSignal?: AbortSignal;
abortController?: AbortController;
};
4 changes: 2 additions & 2 deletions packages/helix-shared-process-queue/src/process-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default async function processQueue(
limit,
interval,
maxConcurrent = 8,
abortSignal,
abortController,
} = typeof rateLimitOptions === 'object'
? rateLimitOptions
: { maxConcurrent: rateLimitOptions || 8 };
Expand Down Expand Up @@ -139,7 +139,7 @@ export default async function processQueue(
for await (const value of iter) {
await waitForToken();

if (abortSignal?.aborted) {
if (abortController?.signal?.aborted) {
return results;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ describe('Process Queue', () => {
maxConcurrent: 2,
limit: 20,
interval: 30000,
abortSignal: abortController.signal,
abortController,
});

// Increase time enough so that all tasks can complete
Expand Down

0 comments on commit 468d46a

Please sign in to comment.