claude-code - 💡(How to fix) Fix computer-use MCP: Swift continuation leak causes screenshot timeout [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45414Fetched 2026-04-09 08:05:58
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Timeline (top)
commented ×1labeled ×1

The computer-use MCP server's captureScreenWithExclusion function leaks its Swift continuation, causing screenshot tasks to hang forever (30s timeout). All other computer-use tools (list_granted_applications, open_application, wait, cursor_position) work fine.

Error Message

SWIFT TASK CONTINUATION MISUSE: captureScreenWithExclusion(displayId:width:height:allowedBundleIds:imageQuality:) leaked its continuation without resuming it. This may cause tasks waiting on it to remain suspended forever.

Root Cause

The Swift function captureScreenWithExclusion uses withCheckedContinuation (or withUnsafeContinuation) but has a code path where continuation.resume() is never called. This leaves the awaiting task suspended forever.

Common patterns that cause this:

  • Guard/early return without resuming
  • SCScreenshotManager completion handler not firing (e.g., invalid display ID, permission denied at capture time)
  • Error callback path missing resume

Fix Action

Workaround

Use claude-in-chrome MCP for browser interaction instead of computer-use screenshots. For native app verification, infer state from API checks rather than visual inspection.

Code Example

SWIFT TASK CONTINUATION MISUSE: captureScreenWithExclusion(displayId:width:height:allowedBundleIds:imageQuality:) leaked its continuation without resuming it. This may cause tasks waiting on it to remain suspended forever.

---

/Applications/Claude.app/Contents/Resources/app.asar.unpacked/node_modules/@ant/claude-swift/build/Release/computer_use.node

---

return await withCheckedContinuation { continuation in
    var resumed = false
    let safeResume: (CGImage?) -> Void = { value in
        guard !resumed else { return }
        resumed = true
        continuation.resume(returning: value)
    }
    
    guard displayId != kCGNullDirectDisplay else {
        safeResume(nil)
        return
    }
    
    performCapture(...) { result in
        switch result {
        case .success(let image): safeResume(image)
        case .failure: safeResume(nil)
        }
    }
}
RAW_BUFFERClick to expand / collapse

Summary

The computer-use MCP server's captureScreenWithExclusion function leaks its Swift continuation, causing screenshot tasks to hang forever (30s timeout). All other computer-use tools (list_granted_applications, open_application, wait, cursor_position) work fine.

Error

SWIFT TASK CONTINUATION MISUSE: captureScreenWithExclusion(displayId:width:height:allowedBundleIds:imageQuality:) leaked its continuation without resuming it. This may cause tasks waiting on it to remain suspended forever.

Reproduction

  1. Open Claude Code (CLI) or Claude Desktop
  2. Use the computer-use MCP server
  3. Call request_access for an app (e.g., Google Chrome) - succeeds
  4. Call screenshot - hangs for 30s then returns timeout error: computer-use native call exceeded 30000ms
  5. All subsequent screenshot calls also fail

Environment

  • macOS 15.5 (Darwin 24.6.0)
  • Claude Desktop 1.1062.0
  • Screen Recording permission granted for "Claude" in System Settings > Privacy & Security
  • Single monitor (also reproduced with dual monitor setup)
  • Toggling Screen Recording permission off/on does not fix it
  • /mcp reconnect does not fix it

Root Cause

The Swift function captureScreenWithExclusion uses withCheckedContinuation (or withUnsafeContinuation) but has a code path where continuation.resume() is never called. This leaves the awaiting task suspended forever.

Common patterns that cause this:

  • Guard/early return without resuming
  • SCScreenshotManager completion handler not firing (e.g., invalid display ID, permission denied at capture time)
  • Error callback path missing resume

Affected Binary

/Applications/Claude.app/Contents/Resources/app.asar.unpacked/node_modules/@ant/claude-swift/build/Release/computer_use.node

Suggested Fix

Wrap the continuation in a safe-resume pattern:

return await withCheckedContinuation { continuation in
    var resumed = false
    let safeResume: (CGImage?) -> Void = { value in
        guard !resumed else { return }
        resumed = true
        continuation.resume(returning: value)
    }
    
    guard displayId != kCGNullDirectDisplay else {
        safeResume(nil)
        return
    }
    
    performCapture(...) { result in
        switch result {
        case .success(let image): safeResume(image)
        case .failure: safeResume(nil)
        }
    }
}

Workaround

Use claude-in-chrome MCP for browser interaction instead of computer-use screenshots. For native app verification, infer state from API checks rather than visual inspection.

extent analysis

TL;DR

The most likely fix for the screenshot task hanging issue is to wrap the continuation in a safe-resume pattern to ensure it is always resumed.

Guidance

  • Verify that the captureScreenWithExclusion function is using withCheckedContinuation or withUnsafeContinuation and identify any code paths where continuation.resume() might not be called.
  • Check for common patterns that cause this issue, such as guard/early return without resuming, SCScreenshotManager completion handler not firing, or error callback path missing resume.
  • Apply the suggested fix by wrapping the continuation in a safe-resume pattern, as shown in the provided code snippet.
  • Consider using the claude-in-chrome MCP for browser interaction instead of computer-use screenshots as a temporary workaround.

Example

The provided code snippet demonstrates how to wrap the continuation in a safe-resume pattern:

return await withCheckedContinuation { continuation in
    var resumed = false
    let safeResume: (CGImage?) -> Void = { value in
        guard !resumed else { return }
        resumed = true
        continuation.resume(returning: value)
    }
    
    // ...
}

Notes

The suggested fix assumes that the issue is caused by a missing continuation.resume() call in the captureScreenWithExclusion function. If the issue persists after applying the fix, further debugging may be necessary to identify the root cause.

Recommendation

Apply the workaround by using claude-in-chrome MCP for browser interaction instead of computer-use screenshots, as this may provide a temporary solution while the underlying issue is being addressed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING