Skip to content

[Medium] Audio capture preload onstop handler has no .catch (unhandled rejection) #15

Open

Description

@adilei

Severity

Medium — unhandled promise rejection on the audio stop path.

Location

electron/audio/capture-preload.cjs:119–143 — the MediaRecorder onstop handler performs async work (finalizing/flushing the segment) but is not wrapped in try/catch and its returned promise has no .catch.

Mechanism

If the finalize/flush inside onstop throws or rejects, the rejection is unhandled. Depending on renderer/preload settings this surfaces as an unhandledRejection and the failure is silently lost rather than surfaced to the controller.

Impact

A failed final audio segment can be dropped without the user or the recorder controller being told, yielding a session with silently missing narration.

Suggested fix

Wrap the onstop body in try/catch (or attach .catch) and post an explicit error back over IPC so the controller can mark the audio segment failed.

Regression test to add (npm test)

This lives in preload (.cjs) so it's awkward to unit test directly; extract the finalize logic into a testable function and assert it reports (rather than swallows) a thrown error. If left in preload, cover via a targeted integration check. Not an evals/ concern.

Activity

  1. added a commit that references this issue on Sep 25, 2026
    59833af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions