{"record":{"id":"89c1b0348db86406","repo":"Hmbown/CodeWhale","slug":"recording-recording-id-already-running","errorCode":null,"errorMessage":"recording ${recording.id} already running","messagePattern":"recording (.+?) already running","errorType":"exception","errorClass":"ExecError","httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/src/backends/harmonyos.mjs","lineNumber":273,"sourceCode":"    },\n    set_value: async ({ target, value }) => {\n      const b = await centerOf(target);\n      await uiInput([\"click\", String(b.cx), String(b.cy)]);\n      await new Promise((r) => setTimeout(r, 300));\n      await uiInput([\"inputText\", String(b.cx), String(b.cy), escDeviceText(String(value))]);\n      return { action_sent: true, strategy: \"uitest-element\" };\n    },\n    select_text: async () => { throw new ExecError(\"select_text is not exposed by uitest dumpLayout/uiInput on the harmony backend\"); },\n    perform_action: async ({ target, action }) => {\n      const b = await centerOf(target);\n      if (action === \"longClick\") return uiInput([\"longClick\", String(b.cx), String(b.cy)]);\n      return uiInput([\"click\", String(b.cx), String(b.cy)]);\n    },\n    read_clipboard: async () => { throw new ExecError(\"clipboard read is not exposed by hdc on current HarmonyOS builds\"); },\n    write_clipboard: async () => { throw new ExecError(\"clipboard write is not exposed by hdc on current HarmonyOS builds\"); },\n    cursor_position: async () => { throw new ExecError(\"cursor position does not exist on touch devices\"); },\n    recordingStart: async ({ intervalMs = 400 } = {}) => {\n      if (recording) throw new ExecError(`recording ${recording.id} already running`);\n      if (!(await have(\"ffmpeg\"))) throw new ExecError(\"ffmpeg is required on the host to mux harmony snapshot-series recordings\");\n      const id = crypto.randomBytes(4).toString(\"hex\");\n      const dir = fs.mkdtempSync(path.join(os.tmpdir(), `cu-rec-${id}-`));\n      const startedAt = new Date().toISOString();\n      const rec = recording = { id, dir, startedAt, intervalMs, seq: 0, controller: new AbortController() };\n      const tick = () => {\n        if (rec.stopped || rec.pending) return rec.pending;\n        rec.pending = (async () => {\n          const opts = { timeoutMs: 15_000, signal: rec.controller.signal };\n          const remote = `${DEVICE_TMP}-rec-${id}-${String(rec.seq).padStart(5, \"0\")}.jpeg`;\n          try {\n            await deviceOut([\"snapshot_display\", \"-f\", remote], opts);\n            await exec.pullFile(remote, path.join(dir, `f${String(rec.seq).padStart(5, \"0\")}.jpeg`), opts);\n            rec.seq++;\n          } finally { await shell([\"rm\", \"-f\", remote], opts).catch(() => {}); }\n        })().catch(() => {}).finally(() => { rec.pending = null; });\n        return rec.pending;\n      };","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/src/backends/harmonyos.mjs#L255-L291","documentation":"`recordingStart` refuses to start a second screen recording while one is already active in this backend instance. The HarmonyOS backend supports exactly one snapshot-series recording at a time (`recording` singleton); starting another without stopping the first throws with the existing recording's id.","triggerScenarios":"Calling `recordingStart()` when a previous `recordingStart()` has not yet been finished with `recordingStop()` (backends/harmonyos.mjs:273). The message embeds the currently running recording's id.","commonSituations":"Retrying a failed recordingStop and then starting again; two parallel automation tasks both starting recordings; forgetting to stop a recording after capturing an action sequence.","solutions":["Call `recordingStop({ id: <running id from the error message> })` before starting a new recording.","Check `recordingStatus()`/`recordingList()` before calling recordingStart.","Reuse the existing recording instead of starting a new one."],"exampleFix":"// before\nawait backend.recordingStart({ intervalMs: 400 }); // throws if one is running\n// after\nconst st = backend.recordingStatus?.({ id: lastRecordingId });\nif (st?.running) await backend.recordingStop({ id: lastRecordingId });\nconst rec = await backend.recordingStart({ intervalMs: 400 });","handlingStrategy":"validation","validationCode":"const st = backend.recordingStatus?.({ id: activeRecordingId });\nif (st?.running) throw new Error(\"a recording is already active: \" + activeRecordingId);","typeGuard":"const canStart = !recordingState.active;","tryCatchPattern":"try { rec = await backend.recordingStart({ intervalMs: 400 }); }\ncatch (e) {\n  const m = String(e.message).match(/recording (\\S+) already running/);\n  if (m) await backend.recordingStop({ id: m[1] }).catch(() => {});\n  else throw e;\n}","preventionTips":["Track recording state in one place in your app","Always pair recordingStart with recordingStop in finally blocks","Parse the running id from the message to recover"],"tags":["recording","state-conflict","harmonyos"],"backgroundTag":"invalid-state-transition","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}