Skip to content

fix(desktop): Gmail import deadlock on large mailboxes (#8797)#8803

Merged
kodjima33 merged 1 commit into
mainfrom
watchdog/issue-8797-gmail-import-deadlock
Jul 1, 2026
Merged

fix(desktop): Gmail import deadlock on large mailboxes (#8797)#8803
kodjima33 merged 1 commit into
mainfrom
watchdog/issue-8797-gmail-import-deadlock

Conversation

@kodjima33

@kodjima33 kodjima33 commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Bug

The macOS Gmail/Email connector hangs indefinitely on Importing… / Connecting to Gmail and never completes — no counts, no error (#8797, p0).

Root cause

GmailReaderService.fetchGmailViaAtomFeedSingle launched the Python helper, then:

try process.run()
process.waitUntilExit()
let output = pipe.fileHandleForReading.readDataToEndOfFile()

When the helper prints a large JSON payload (up to 300 emails) to stdout, the pipe buffer fills, the child blocks in write(2), and the parent blocks in waitUntilExit() — a classic pipe deadlock. The UI spins forever with no timeout/error path.

Fix

  • Drain stdout/stderr asynchronously via readabilityHandler while the helper runs, then waitUntilExit() — the child can never block on a full buffer.
  • Add a 60s terminate timeout so a stuck/slow helper surfaces an actionable error ("produced no output") instead of hanging.
  • Mirrors the vetted safe pattern already used in CalendarReaderService.

Scope: one file (+ changelog fragment), ~40 lines. Compiles clean (xcrun swift build -c debug, Build complete).

🤖 automated by hourly watchdog; opened for review, not merged.

Review in cubic

…8797)

The Gmail/Email connector launched a Python helper, called
process.waitUntilExit(), then read stdout via readDataToEndOfFile().
When the helper emits a large JSON payload (up to 300 emails), the stdout
pipe buffer fills, the child blocks in write(2), and the parent blocks in
waitUntilExit() -> the import spins on 'Importing...' forever with no error.

Drain stdout/stderr asynchronously via readabilityHandler while the helper
runs, and add a 60s terminate timeout so a stuck/slow helper surfaces an
actionable error instead of hanging. Mirrors the existing safe pattern in
CalendarReaderService.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@kodjima33 kodjima33 merged commit d12260b into main Jul 1, 2026
2 checks passed
@kodjima33 kodjima33 deleted the watchdog/issue-8797-gmail-import-deadlock branch July 1, 2026 22:55
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.

1 participant