Skip to content

Import: closing the recorder mid-save can leave a clip or an empty draft behind #272

Closed

Description

@morepriyam

Raised in review on #240 (src/features/recorder/use-recorder.ts, the library import).

What happens

After the import's conversion finishes, the recorder still runs four steps with no cancel check between them: it creates the draft if needed (ensureDraft), copies the file into the draft, reads its length, and saves the clip (persistSegment). If the recorder is closed during those steps:

  • the clip can still be added to a draft the person already left, or a new draft can be created after the screen is gone;
  • the recorder's close-time cleanup, which deletes a draft that looks empty, can delete the draft this import is still writing to.

It's rare: those steps take a fraction of a second after a conversion that can take much longer. From reading the code; not reproduced.

Fix

  • Check the import's abort signal after each of those steps, and before saving the clip.
  • On a cancel, delete the copied file, and delete the draft if this import created it.
  • Make the close-time cleanup wait for an import in flight (or skip a draft an import is writing to), so it can't delete a draft that is being saved.

Done when

Closing the recorder at any point of an import leaves either the clip saved in its draft or nothing at all: no stray file, no empty draft, no clip added after the screen is gone.

Activity

  1. added a commit that references this issue on Oct 15, 2026
    29316c1
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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions