Description
pool.queueSize is incorrect when tasks are submitted with a signal. In that case, tasks that cannot be scheduled immediately may end up in skipQueue, but the queueSize getter only accounts for taskQueue. As a result, queued tasks in skipQueue are not reflected in pool.queueSize, which can remain 0 even though tasks are clearly waiting.
Reproduction
const piscina = require('piscina');
const pool = new Piscina({
filename: './worker.js',
minThreads: 1,
maxThreads: 1,
});
const controller = new AbortController();
const promises = []
for (let i = 0; i < 10; i++) {
const promise = pool.run({
reqId,
timestamp: Date.now()
}, { signal: controller.signal });
console.log(`[REQ ${i.toString().padStart(3)}] queueSize: ${pool.queueSize}, threads: ${pool.threads.length}, completed: ${pool.completed}`);
promises.push(promise);
}
await Promise.all(promises);
// worker.js
module.exports = async ({ reqId }) => {
await new Promise((resolve) => setTimeout(resolve, 2000));
return reqId;
};
With signal the queueSize is always 0. Without signal the queueSize is correct.
Environment
- OS: Windows 11
- Node.js version: 22.14.0
- Piscina version: 5.1.4
Expected Behavior
queueSize should reflect the number of tasks currently waiting to be executed, regardless of whether those tasks were submitted with an AbortSignal or not.
Description
pool.queueSize is incorrect when tasks are submitted with a signal. In that case, tasks that cannot be scheduled immediately may end up in skipQueue, but the queueSize getter only accounts for taskQueue. As a result, queued tasks in skipQueue are not reflected in pool.queueSize, which can remain 0 even though tasks are clearly waiting.
Reproduction
With signal the queueSize is always 0. Without signal the queueSize is correct.
Environment
Expected Behavior
queueSize should reflect the number of tasks currently waiting to be executed, regardless of whether those tasks were submitted with an AbortSignal or not.