Skip to content

Fix crash caused by calling checked continuation multiple times - #112

Merged
mattt merged 8 commits into
mainfrom
mattt/fix-continuation-misuse
Jan 28, 2026
Merged

mattt merged 8 commits into
mainfrom
mattt/fix-continuation-misuse

Conversation

@mattt

@mattt mattt commented Nov 20, 2025

Copy link
Copy Markdown
Owner

Resolves #111

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses crashes caused by calling checked continuations multiple times, fixing issue #111. The solution implements synchronization mechanisms to ensure continuations are only resumed once, even when multiple state changes or callbacks occur.

Key Changes

  • Introduced a ConnectionState actor in CLI/main.swift to track continuation resumption state
  • Added NSLock-based resumeOnce patterns in Capture.swift and ServerController.swift to prevent double-resume in concurrent scenarios
  • Updated state handlers to check resumption status before calling continuation.resume()

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
CLI/main.swift Added ConnectionState actor and updated handleConnectionState to track and prevent duplicate continuation resumptions during network state changes
App/Services/Capture.swift Implemented NSLock-protected resumeOnce closures for camera and screenshot capture timeouts to prevent race conditions
App/Controllers/ServerController.swift Added NSLock-protected resumeOnce pattern for connection approval handling to ensure single continuation resumption

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CLI/main.swift Resolved
Comment thread CLI/main.swift Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CLI/main.swift Resolved
Comment thread CLI/main.swift Resolved
Comment thread App/Services/Capture.swift Resolved
Comment thread App/Services/Capture.swift Resolved
@mattt
mattt merged commit c9daec8 into main Jan 28, 2026
@mattt
mattt deleted the mattt/fix-continuation-misuse branch January 28, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App crashes with "CheckedContinuation resumed multiple times" after running for ~12 minutes

2 participants