mqtt2ha
    Preparing search index...

    Function serializeAsync

    • Wraps an async function so that its invocations run one at a time, in call order. Each call waits for the previous one to settle before starting, turning overlapping calls into a serial queue.

      This is used to serialize command handling per component: a component that awaits a device command before publishing its confirmed state could otherwise let an older command publish after a newer one (a slow command completing last), leaving Home Assistant showing a stale state. Serializing guarantees each command is fully applied and published before the next one begins.

      A rejection from one call is isolated so it does not wedge the queue: the returned promise still rejects (so the caller can observe and log the failure), but the internal chain swallows it so later calls keep running.

      Type Parameters

      • TArgs extends unknown[]
      • TResult

      Parameters

      • fn: (...args: TArgs) => Promise<TResult>

        The async function to serialize

      Returns (...args: TArgs) => Promise<TResult>

      A function with the same signature whose calls are queued and run sequentially