AsyncQueuer: concurrency > 1 not honoured for items added while another is executing (regression in 0.22.0)
维护者通常 2 天内回复
评估
- 难度
- 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:
- Create an
AsyncQueuerwith{ concurrency: 2, wait: 0 }and a task that stays pending (a long download, say). - Call
addItem("a"), thenaddItem("b"). - 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 小时
- 30 天内合并 PR
- 11
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/pacer 的其他 Issue
-
replace deprecated Vitest spy assertion aliases可能已有人在做 @2yunseong 于 22 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 2 天内回复
-
Queued AsyncDebounce execution is silently dropped if it is executed after an in-flight run completes可能已有人在做 @SimenB 于 14 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 75/100
维护者通常 2 天内回复
-
Async utilities count swallowed retryer failures as successes and call onSuccess(undefined)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 2 天内回复
-
debouncer.getAbortSignal() returns null due to maybeExecuteCount increment mismatch可能已有人在做 @SimenB 于 14 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
维护者通常 2 天内回复
-
with devtools added getting export setStyleProperty was not found in module error可能已有人在做 @restareaByWeezy 于 212 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 48/100
TanStack/pacer#131 · 3 条评论 · 4 个 reaction ·
维护者通常 2 天内回复
相似的 Issue
-
ble-needs-fable-review bug mobile priority:P2
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
ColeMurray/background-agents#2305 ·
维护者通常 1 天内回复
-
bug from-studio
难度 2/5 1-3 小时 新手友好度 63/100
esengine/DeepSeek-Reasonix#12355 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
oblien/openship#1086 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复