feat: 按任务管理比特浏览器临时窗口

This commit is contained in:
2026-09-23 18:15:08 +08:00
parent 04309f60c7
commit ff2879f102
15 changed files with 577 additions and 226 deletions
@@ -97,6 +97,26 @@ function yieldEventLoop() {
assert.strictEqual(deferredBatch.completed, 3, '延迟重试不应重复累计完成进度');
assert.strictEqual(deferredBatch.results[0].attempt, 2, '延迟项目到期后应在原索引写入最终结果');
const heldSlotRuns = [];
const heldSlotAttempts = new Map();
const heldSlotBatch = await runConcurrentItems(['sleeping', 'next'], async item => {
heldSlotRuns.push(item);
const attempt = (heldSlotAttempts.get(item) || 0) + 1;
heldSlotAttempts.set(item, attempt);
if (item === 'sleeping' && attempt === 1) return { defer: true, delayMs: 20 };
return { item, attempt };
}, {
concurrency: 1,
deferReleasesSlot: false,
getDeferDelay: result => (result && result.defer ? result.delayMs : 0),
});
assert.deepStrictEqual(
heldSlotRuns,
['sleeping', 'sleeping', 'next'],
'临时比特浏览器任务延迟等待时必须占住串行槽,删除后才能轮到下一账号',
);
assert.strictEqual(heldSlotBatch.completed, 2, '占住串行槽时仍应完成全部项目');
console.log('concurrent_runner_resilience.test.js: PASS');
})().catch(error => {
console.error(error);