Skip to content

Roll back session uploads on client disconnect and cancellation #17

Closed

Description

@cchacs

Audited main at a7bad12. Existing tests pass: 33 Python, 9 JavaScript.

routes.py append_session_video and upload_session_audio only clean up on OSError/ValueError. Starlette raises ClientDisconnect when a streamed request disconnects; task cancellation also bypasses these handlers.

Reproduced by calling the registered endpoints with a request stream that yields b'partial' and then raises ClientDisconnect. Both frames.h264 and audio.bin retain those partial bytes. The next audio upload returns 409 because audio.bin exists. Video accounting remains at its pre-request value despite the extra bytes, so a retry can corrupt the elementary stream and its cumulative cap no longer reflects disk contents.

Please roll video back to its accepted prefix and remove incomplete audio on every unsuccessful stream exit, including disconnect/cancellation. Preserve cancellation semantics after cleanup. Add interrupted-stream tests verifying exact video contents/counter and a successful audio retry.

Activity

  1. pullfrog commented on Oct 11, 2026

    @pullfrog
    Contributor
  2. pullfrog commented on Oct 11, 2026

    @pullfrog
    Contributor

    Implemented #17 and opened PR #19: #19

    Session uploads now roll back on every unsuccessful stream exit. In routes.py, the video append catches BaseException (so ClientDisconnect and CancelledError are no longer missed), truncates frames.h264 back to the accepted prefix, and restores the video_bytes counter inside the append lock; the audio upload removes the incomplete audio.bin. Both re-raise, preserving cancellation semantics.

    Added 4 asyncio interrupted-stream tests (disconnect + cancellation for video and audio) that verify exact video contents/counter and a successful audio retry. All 4 were confirmed to fail against the unpatched routes.py. Full suite: 37 passed. Bumped plugin.json to 0.3.2 and updated CHANGELOG.md/CLAUDE.md.

    Task list (7/7 completed)
    • Create feature branch
    • Roll back video and remove audio on BaseException (disconnect/cancel) in routes.py
    • Add interrupted-stream tests (video + audio retry)
    • Bump plugin.json version and update CHANGELOG
    • Run full test suite
    • Self-review via reviewfrog subagent
    • Commit, push, open PR

    Pullfrog  | View workflow run | via Pullfrog | Using big-pickle (free) | 𝕏

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