Here `splice` also unnecessary generates an array of 1024 tasks.
How about `queue = queue.slice(capacity);`?