Cysharp/UniTask · error · InvalidOperationException

EmptyQueue

Error message

EmptyQueue

What it means

Thrown by MinimumQueue.ThrowForEmptyQueue() when Dequeue or Peek is called on a queue with size == 0. MinimumQueue is internal; all legitimate callers (ArrayPool, player-loop runners) check Count before dequeuing. If this fires it indicates a logic bug in the internal consumer or source modification.

Source

Thrown at src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/MinimumQueue.cs:109

            array = newarray;
            head = 0;
            tail = (size == capacity) ? 0 : size;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void MoveNext(ref int index)
        {
            int tmp = index + 1;
            if (tmp == array.Length)
            {
                tmp = 0;
            }
            index = tmp;
        }

        void ThrowForEmptyQueue()
        {
            throw new InvalidOperationException("EmptyQueue");
        }
    }
}

View on GitHub (pinned to ceac8d6946)

Solutions

  1. This should not occur in normal usage. Report it as a UniTask issue with a reproduction case.
  2. Verify you are using an unmodified, released version of UniTask.
  3. Check for unsafe memory operations or native plugin interference that could corrupt internal state.
Defensive patterns

Strategy: validation

Validate before calling

// This is an internal guard not reachable through public API.
// No user-facing validation is needed.
// If encountered, report as a UniTask bug.

Prevention

When it happens

Trigger: Internal: a race condition or invariant violation in ArrayPool's Rent/Return or in ContinuationQueue/PlayerLoopRunner causing a dequeue on an empty queue. Not reachable through normal UniTask public API.

Common situations: Not applicable for end users. Would indicate a UniTask internal bug, source modification, or memory corruption.

Related errors


AI-assisted analysis of Cysharp/UniTask@ceac8d6946 (2026-08-13). Data as JSON: /api/errors/38530cf346d57402. Report an issue: GitHub.