Skip to content

fix: clean up leaked observers, untracked tasks, and misleading log#218

Merged
datlechin merged 2 commits intomainfrom
fix/resource-cleanup-audit
Mar 9, 2026
Merged

fix: clean up leaked observers, untracked tasks, and misleading log#218
datlechin merged 2 commits intomainfrom
fix/resource-cleanup-audit

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #217. Full resource cleanup audit found 3 additional issues:

  • URL filter notification observers never removedsetupURLNotificationObservers() registered two block-based NotificationCenter observers but never stored the returned NSObjectProtocol tokens. Each window open/close accumulated 2 orphaned observers. Now stores tokens and removes them in teardown().
  • Untracked metadata driver creation TasksconnectToSession() and reconnectSession() spawned fire-and-forget Task {} blocks to create metadata drivers that were never stored or cancelled. If disconnectSession() ran before completion, the task could assign a driver to a stale session. Now tracked in metadataCreationTasks and cancelled on disconnect.
  • Misleading health monitor log message — Log said "after 3 retries" but ConnectionHealthMonitor retries indefinitely with exponential backoff. Fixed the message.

Also adds docs/development/resource-cleanup-audit.md tracking all findings from the audit.

Closes #214

Test plan

  • Build succeeds
  • Connect via SSH tunnel, close window, verify no leaked processes
  • Open/close multiple connection windows, verify no observer accumulation
  • Disconnect while metadata driver is still loading, verify no stale assignment

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin datlechin merged commit d4ca88e into main Mar 9, 2026
2 checks passed
@datlechin datlechin deleted the fix/resource-cleanup-audit branch March 9, 2026 04:06
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.

Bug: ssh tunnel not closed after closing window

1 participant