Skip to content

Exempt connections awaiting approval from the setup timeout - #200

Merged
mattt merged 2 commits into
mainfrom
fix/approval-timeout
Sep 2, 2026
Merged

mattt merged 2 commits into
mainfrom
fix/approval-timeout

Conversation

@mattt

@mattt mattt commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Fixes #193.

handleNewConnection races setup against a 10-second stall timer, but setup includes waiting for the person to answer the approval dialog. A first connection from an untrusted client was torn down before anyone could click Allow, which is exactly the "first attempt fails, retry works" pattern reported here and in #24.

The connection is now recorded as awaiting approval for the duration of the approval handler, and the timeout check skips it. The handshake before the prompt is still covered by the timer, and a denied dialog still closes the connection through the existing path.

No automated test: the app target has no test bundle, and this sits behind the approval UI. Verified by build; a manual check is connecting a fresh client and waiting longer than 10 seconds before clicking Allow.

handleNewConnection races connection setup against a 10-second stall
timer, but setup includes waiting for the user to answer the approval
dialog. A first connection from a new client was therefore torn down
before anyone could click Allow, which is why the first attempt always
failed and the retry (now trusted) succeeded.

Track connections whose setup is blocked on the approval handler and
skip them in the timeout check. The handshake before the prompt is
still covered, and a denied dialog still closes the connection.

Fixes #193.

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.

🟡 Changes recommended

The one-shot timer can still time out near-deadline approvals or permanently disable post-approval timeout enforcement.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Exempts connections awaiting user approval from the setup timeout.

Changes:

  • Tracks connections awaiting approval.
  • Skips those connections during timeout checks.
File summaries
File Description
App/Controllers/ServerController.swift Adds approval-wait tracking to timeout logic.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread App/Controllers/ServerController.swift Resolved
A one-shot timer that merely skipped connections awaiting approval could
still close a connection approved just before the deadline, and stopped
enforcing anything once approval finished. Keep a timer per connection:
cancel it when the approval handler starts, give the connection a fresh
budget when approval returns, and clear it when setup ends.

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.

🟢 Approval recommended

The focused timer lifecycle changes correctly address the reported approval race without altering denial handling.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@mattt
mattt merged commit 4e646f8 into main Sep 2, 2026
2 checks passed
@mattt
mattt deleted the fix/approval-timeout branch September 2, 2026 19:25
toonvl added a commit to toonvl/iMCP that referenced this pull request Sep 2, 2026
Brings in the six upstream commits behind #2: the SIGTRAP
continuation fix (mattt#151), the Bonjour browser cleanup (mattt#199), the approval
setup-timeout exemption (mattt#200), the events_fetch date-only fix (mattt#175),
Madrid 0.5.0 with FetchRequest<Message> (mattt#201), and message read status
(mattt#195).

Three files conflicted, all because upstream shipped its own version of a
fix this fork already carried:

- CLI/main.swift: took upstream. Its mattt#199 supersedes our inline
  browser.cancel() (our closed upstream PR mattt#196) by extracting
  BonjourDiscovery.discoverEndpoint, which cancels on every exit path and
  comes with tests.
- App/Extensions/Foundation+Extensions.swift: took upstream. Its
  `count > 10` guard on the timezone-suffix regex is equivalent to our
  `!isDateOnlyISO8601String(...)`; staying identical to upstream is worth
  more than the marginal precision.
- App/Services/Calendar.swift: kept ours. Upstream only annotates
  `identifier` on the events_fetch and events_create returns, which our
  private encode(_:) helper already does alongside organizedByMe,
  organizer, isRecurring and coordinates.

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants