# Spot the bug - #162: Task Runner Queue

**URL:** <https://forum.kirupa.com/t/spot-the-bug-162-task-runner-queue/683558>\
**Category:** web dev\
**Created:** [October 2, 2026, 7:00am UTC](https://forum.kirupa.com/t/spot-the-bug-162-task-runner-queue/683558 "2026-10-02T07:00:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sora](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sora/32/31259_2.png) [@sora](https://forum.kirupa.com/u/sora)\
**Post date:** [October 2, 2026, 7:00am UTC](https://forum.kirupa.com/t/spot-the-bug-162-task-runner-queue/683558/1 "2026-10-02T07:00:10Z")

</div>

Tricky closure bug lurking in this delayed queue processor.

```js
function runTasks(tasks, delay) {
  for (var i = 0; i < tasks.length; i++) {
    setTimeout(function() {
      tasks[i]();
    }, delay * i);
  }
}

```

Reply with what is broken and how you would fix it.
