Skip to content

fix(mecatui): stop a lost MCP-authorization stream signal from killing polling - #1282

Merged
jhrozek merged 1 commit into
mainfrom
fix/mcp-authorization-poll-stall
Sep 9, 2026
Merged

jhrozek merged 1 commit into
mainfrom
fix/mcp-authorization-poll-stall

Conversation

@jhrozek

@jhrozek jhrozek commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Live-tested against connector-gateway.stacklok.dev/DCR: after granting an
on-demand tool's authorization in the browser, mecatui sometimes sat "stuck"
for minutes with no error, occasionally requiring an unrelated keypress
before it noticed the grant.

Root cause: applyMCPAuthorizationPollTick only reschedules the next 3s poll
tick from inside a completed control's own callback chain. If a single
RecheckMCPAuthorization call's stream never delivers its terminal
close/error signal — a dropped HTTP/2 stream-end frame over a flaky
port-forward/ngrok hop, confirmed live via a stuck single-TCP-connection
gRPC channel — pollBusy stays true forever and the tick handler's guard
silently no-ops without rescheduling. There was no timeout anywhere in
startMCPAuthorizationControl's context, so this could hang indefinitely.

Add a first-event watchdog: cancel the call's context if no event arrives
within mcpAuthorizationFirstEventTimeout (10s), which surfaces as an
ordinary stream error already handled by the existing recovery path (resets
pollBusy, reschedules the next tick). The watchdog is stopped as soon as any
event/error/close is observed, so a genuinely long-running granted
continuation's drain is never bounded by it.

Also adds DEBUG-level tracing through the server-side authorization control
flow (RecheckMCPAuthorization, the granted-continuation path, terminal
resolution), used to rule out a server-side race during live debugging —
the server was consistently fast and correct; the stall was client-only.

Co-Authored-By: mecatl [email protected]

…g polling

Live-tested against connector-gateway.stacklok.dev/DCR: after granting an
on-demand tool's authorization in the browser, mecatui sometimes sat "stuck"
for minutes with no error, occasionally requiring an unrelated keypress
before it noticed the grant.

Root cause: applyMCPAuthorizationPollTick only reschedules the next 3s poll
tick from inside a completed control's own callback chain. If a single
RecheckMCPAuthorization call's stream never delivers its terminal
close/error signal — a dropped HTTP/2 stream-end frame over a flaky
port-forward/ngrok hop, confirmed live via a stuck single-TCP-connection
gRPC channel — pollBusy stays true forever and the tick handler's guard
silently no-ops without rescheduling. There was no timeout anywhere in
startMCPAuthorizationControl's context, so this could hang indefinitely.

Add a first-event watchdog: cancel the call's context if no event arrives
within mcpAuthorizationFirstEventTimeout (10s), which surfaces as an
ordinary stream error already handled by the existing recovery path (resets
pollBusy, reschedules the next tick). The watchdog is stopped as soon as any
event/error/close is observed, so a genuinely long-running granted
continuation's drain is never bounded by it.

Also adds DEBUG-level tracing through the server-side authorization control
flow (RecheckMCPAuthorization, the granted-continuation path, terminal
resolution), used to rule out a server-side race during live debugging —
the server was consistently fast and correct; the stall was client-only.

Co-Authored-By: mecatl <[email protected]>
@jhrozek
jhrozek merged commit d446945 into main Sep 9, 2026
31 checks passed
@jhrozek
jhrozek deleted the fix/mcp-authorization-poll-stall branch September 9, 2026 10:05
JAORMX pushed a commit that referenced this pull request Sep 9, 2026
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