#3275·inertia

Queue can leave tasks pending when they are added as a drain completes

Author: gianpieropuleoCreated Sep 25, 2026Updated Sep 25, 2026

Inertia adapter(s) affected

React, Vue 3, and Svelte share the affected core queue. The reproduction below does not need an adapter or browser.

JS package version

@inertiajs/core 3.7.1. The same queue implementation is present on 3.x at b70a1d1e8172e72c980c8e3b39eda22adbb14576.

Backend stack

Not applicable.

Describe the problem

Queue.processNext() can reach an empty queue before the finalizer in Queue.process() clears processingPromise. If another task arrives in that interval, add() returns the existing promise without starting a new drain. The finalizer then clears that promise, but leaves the new task pending.

The returned promise resolves even though the task did not run. A later call to add() or process() runs the pending task. This can delay history updates that use the queue.

The queue should process the added task without another call, and the returned promise should wait for that work.

Steps to reproduce

In an Inertia repository checkout, add this test to tests/core/queue.test.ts:

typescript
import test, { expect } from '@playwright/test'
import Queue from '../../packages/core/src/queue'

test('drains tasks added while the previous drain is settling', async () => {
  const queue = new Queue<void | Promise<void>>()
  const calls: number[] = []
  const first = queue.add(() => {
    calls.push(1)
  })

  await Promise.resolve()

  const second = queue.add(async () => {
    await Promise.resolve()
    calls.push(2)
  })

  await first
  expect(calls).toEqual([1, 2])
  await second
})

After dependency installation, run:

bash
pnpm build:all
PACKAGE=react pnpm exec playwright test tests/core/queue.test.ts --project=chromium

Expected: calls is [1, 2] when the promise completes.

Actual: calls is [1]; the second task remains queued.

This does not require a task to throw or reject. It differs from the error-related queue stall in #2466.