moeru-ai/airi · error · Error

Open the DualSense controller before you send an output repo

Error message

Open the DualSense controller before you send an output report.

What it means

sendOutput() builds a report and writes it to the HID device, which WebHID only allows while the device is open. The guard throws whenever the controller is not in the 'open' lifecycle state — never opened, already closed, or mid-transition — because sendReport on an unopened HIDDevice would reject with a lower-level error anyway; this makes the required ordering explicit at the API boundary.

Source

Thrown at packages/input-playstation-dualsense-5/src/controller.ts:121

  async sendOutput(output: DualSenseOutputState): Promise<void> {
    if (this.#lifecycle !== 'open')
      throw new Error('Open the DualSense controller before you send an output report.')

    const report = buildDualSenseOutputReport(
      this.#connectionType,
      output,
      this.#outputSequenceNumber,
    )
    this.#outputSequenceNumber = report.nextSequenceNumber
    await this.#device.sendReport(report.reportId, report.data)
  }

View on GitHub (pinned to 9c213115f8)

Solutions

  1. Call `await controller.open()` before the first sendOutput and keep the controller open for the session.
  2. Gate output sending on `controller.lifecycle === 'open'` (the getter is public) or pause sending in response to close events.
  3. If outputs fire from a timer, check lifecycle before each send or wrap the send loop in a guard that skips while not open.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/input-playstation-dualsense-5/src/controller.ts:121 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of moeru-ai/airi@9c213115f8 (2026-09-02). Data as JSON: /api/errors/9d4040fe44f686a2. Report an issue: GitHub.