Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

AsyncQueuer: concurrency > 1 not honoured for items added while another is executing (regression in 0.22.0)

オープン
#269 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@KevinVandy がすでに取り組んでいます。

2026年9月30日 から。

  • #271 @KevinVandy による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
66/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
node.js, typescript
領域
backend

調査の方向性

Start with the AsyncQueuer addItem path and its private #tick logic, especially the pendingTick guard described in the issue. Run the linked gist with @tanstack/pacer 0.22.0 and 0.21.1 to compare behavior. Done means adding items while an execution is pending fills every available concurrency slot without bypassing wait behavior.

索引モデルが issue の本文から書いたものです。

説明

TanStack Pacer version

@tanstack/pacer v0.22.0 (via @tanstack/react-pacer v0.23.0). Last working version: @tanstack/pacer v0.21.1 (@tanstack/react-pacer v0.22.1).

Framework/Library version

Reproduced with the core package on Node.js v25.9.0 (no framework). Originally seen through useAsyncQueuer with React v19.3.0.

Describe the bug and the steps to reproduce it

Since @tanstack/pacer 0.22.0, an AsyncQueuer with concurrency: 2 runs items one at a time when they are added one after another, for example one addItem() per user click. The second item waits for the first to finish even though a concurrency slot is free. On 0.21.1 both start immediately.

Steps:

  1. Create an AsyncQueuer with { concurrency: 2, wait: 0 } and a task that stays pending (a long download, say).
  2. Call addItem("a"), then addItem("b").
  3. Check how many tasks have started.

Expected: 2 started, 2 active, 0 pending (what 0.21.1 does).
Actual on 0.22.0: 1 started, 1 active, 1 pending.

import { AsyncQueuer } from "@tanstack/pacer";

let started = 0;
const queuer = new AsyncQueuer(
  async () => {
    started++;
    await new Promise(() => {}); // a long-running task
  },
  { concurrency: 2, wait: 0 },
);

queuer.addItem("a");
queuer.addItem("b");

await new Promise((r) => setTimeout(r, 50));
const { activeItems, items } = queuer.store.state;
console.log({ started, active: activeItems.length, pending: items.length });
@tanstack/pacer output
0.21.1 started=2 active=2 pending=0
0.22.0 started=1 active=1 pending=1

Likely cause: #246 (the fix for #188) keeps pendingTick: true while executions are in flight (#tick: "pendingTick must stay true while executions or wait timers are pending"), and addItem only calls #tick() when !pendingTick. So an item added during an execution isn't picked up until that execution settles and re-ticks, even though a slot is free. main still has the same guard. The #188 intent (don't bypass wait) seems to need the guard only while a wait timer is armed, not while an execution runs with free slots.

(Investigated with AI assistance. The repro and the version comparison above were run and checked by hand.)

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://gist.github.com/ilyaauditoo/710aab918995470c11960aa9e33ff0f0 — npm install && npm start (pins @tanstack/[email protected]; change it to 0.21.1 to see the expected behaviour).

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

Yes, I think I know how to fix it and will discuss it in the comments of this issue

Terms & Code of Conduct
  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
主要言語
TypeScript
スター
776
フォーク
67
平均マージ
1日 15時間
マージ済み PR(30日)
11

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TanStack/pacer のほかの issue

TanStack/pacer の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。