Skip to content

[Medium] deleteSession can race in-flight background post-processing #13

Open

Description

@adilei

Severity

Medium — race between deletion and background work; can corrupt/partially write into a deleted session dir.

Location

  • electron/ipc.ts:196 (deleteSession handler) validates sessionId and refuses deletion only while the session is actively recording (lines 198–199) — it does not account for post-processing.
  • electron/recorder/controller.ts:517 (schedulePostProcess) runs describer/frame work after stop() returns, in the background.

Mechanism

Right after Stop, post-processing (analysis, frame extraction) is still running for the session. Nothing prevents the user from deleting that same session in the same window, so background tasks can write frames/analysis into a directory that deleteSession is concurrently removing.

Impact

Orphaned/partial files, write-after-delete errors, or a resurrected half-session directory.

Suggested fix

Track in-flight post-processing per session id; have deleteSession cancel (or await) it before removing the directory — or refuse deletion with a clear message while post-processing is active (mirroring the active-recording guard).

Regression test to add (npm test)

Unit test: start a fake post-process task for a session, call deleteSession while it's pending, and assert the delete either cancels/awaits it and that no write lands after the directory is removed. Deterministic; not an evals/ concern.

Activity

  1. newbpydev commented on Aug 11, 2026

    @newbpydev

    I’d like to work on this. My proposed narrow fix is to track recorder post-processing by session ID and refuse deletion with a clear message while that session is still processing. I’d add a deterministic regression that holds a fake post-process task open, verifies the session is protected, then verifies deletion becomes available after it resolves; cancellation semantics would remain out of scope.

    I see that #62 targets release/0.5.0 and touches both electron/ipc.ts and electron/recorder/controller.ts, and that 0.5.0 may be released shortly. Would you prefer that I base this on release/0.5.0 now, wait for #62/release to land, or target the next release branch?

  2. adilei commented on Aug 12, 2026

    @adilei
    CollaboratorAuthor

    I’d like to work on this. My proposed narrow fix is to track recorder post-processing by session ID and refuse deletion with a clear message while that session is still processing. I’d add a deterministic regression that holds a fake post-process task open, verifies the session is protected, then verifies deletion becomes available after it resolves; cancellation semantics would remain out of scope.

    I see that #62 targets release/0.5.0 and touches both electron/ipc.ts and electron/recorder/controller.ts, and that 0.5.0 may be released shortly. Would you prefer that I base this on release/0.5.0 now, wait for #62/release to land, or target the next release branch?

    Thanks Juan Gomez (@newbpydev) !

    We'll probably be merging 0.5.0 today or tomorrow so your PR can target 0.6.0 when we have one. Will ping you here.

  3. newbpydev commented on Aug 12, 2026

    @newbpydev

    I’d like to work on this. My proposed narrow fix is to track recorder post-processing by session ID and refuse deletion with a clear message while that session is still processing. I’d add a deterministic regression that holds a fake post-process task open, verifies the session is protected, then verifies deletion becomes available after it resolves; cancellation semantics would remain out of scope.
    I see that #62 targets release/0.5.0 and touches both electron/ipc.ts and electron/recorder/controller.ts, and that 0.5.0 may be released shortly. Would you prefer that I base this on release/0.5.0 now, wait for #62/release to land, or target the next release branch?

    Thanks Juan Gomez (@newbpydev) !

    We'll probably be merging 0.5.0 today or tomorrow so your PR can target 0.6.0 when we have one. Will ping you here.

    Thanks adilei — and congratulations on the 0.5.0 release. Sounds good. I’ll wait for release/0.6.0 and your ping before starting, then keep the PR scoped to the per-session post-processing guard and deterministic regression described above.

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