{"record":{"id":"4f925ab24127416f","repo":"moeru-ai/airi","slug":"the-dualsense-controller-failed-to-open-and-close","errorCode":null,"errorMessage":"The DualSense controller failed to open and close.","messagePattern":"The DualSense controller failed to open and close\\.","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"packages/input-playstation-dualsense-5/src/controller.ts","lineNumber":85,"sourceCode":"    catch (openError) {\n      this.#device.removeEventListener('inputreport', this.#handleInputReport)\n      this.#lifecycle = 'closed'\n      if (!this.#device.opened)\n        throw openError\n\n      try {\n        await this.#device.close()\n      }\n      catch (closeError) {\n        throw new AggregateError(\n          [openError, closeError],\n          'The DualSense controller failed to open and close.',\n        )\n      }\n      throw openError\n    }","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/moeru-ai/airi/blob/9c213115f8bd0fff9e6eabab02b077ac32da21be/packages/input-playstation-dualsense-5/src/controller.ts#L67-L103","documentation":"Raised from open()'s catch block only when two failures stack: the device.open()/receiveFeatureReport(0x05) sequence failed (openError) AND the device was already marked opened, so the rollback attempted device.close() which also failed (closeError). The AggregateError carries both causes; the controller is reset to the 'closed' lifecycle and its inputreport listener removed before throwing. A failure where the device was never opened rethrows the original openError without wrapping.","triggerScenarios":"Thrown at packages/input-playstation-dualsense-5/src/controller.ts:85 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect `error.errors[0]` for the original open failure (e.g. SecurityError from missing WebHID permission) and `error.errors[1]` for the close failure.","Recover by discarding the DualSenseController instance and constructing a fresh one from the HIDDevice after permissions are fixed.","Log both nested errors; the close failure usually means the OS-level HID handle is wedged and may require replugging the controller."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9c213115f8bd0fff9e6eabab02b077ac32da21be","analyzedAt":"2026-09-02T04:27:24.639Z","contentChangedAt":"2026-09-02T04:27:24.639Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}