Description
In the task scheduler implementation, when the stale timeout feature is disabled (set to 0 or negative), completed/rejected tasks are never cleaned up from the internal task queue. Over time this causes unbounded memory growth.
Impact
- Memory leak in long-running applications
- Gradual performance degradation as the task list grows
- Eventually may cause OOM in Node.js services or browser tab crashes
Steps to Reproduce
javascript const scheduler = createTaskScheduler({ staleTimeout: 0 }); // Process many tasks over time for (let i = 0; i < 100000; i++) { scheduler.queue(() => Promise.resolve()); } // Internal task list never shrinks
Suggested Fix
Ensure tasks are removed from the internal list upon completion/rejection regardless of the stale timeout configuration. The stale timeout should only govern how long to wait for unresolved tasks, not whether completed tasks are cleaned up.
Severity
Medium — memory leak that manifests in long-running services.
Description
In the task scheduler implementation, when the stale timeout feature is disabled (set to 0 or negative), completed/rejected tasks are never cleaned up from the internal task queue. Over time this causes unbounded memory growth.
Impact
Steps to Reproduce
javascript const scheduler = createTaskScheduler({ staleTimeout: 0 }); // Process many tasks over time for (let i = 0; i < 100000; i++) { scheduler.queue(() => Promise.resolve()); } // Internal task list never shrinksSuggested Fix
Ensure tasks are removed from the internal list upon completion/rejection regardless of the stale timeout configuration. The stale timeout should only govern how long to wait for unresolved tasks, not whether completed tasks are cleaned up.
Severity
Medium — memory leak that manifests in long-running services.