Repository navigation
fix(mecatui): stop a lost MCP-authorization stream signal from killing polling - #1282
Merged
Merged
Conversation
…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]>
JAORMX
pushed a commit
that referenced
this pull request
Sep 9, 2026
…g polling (#1282) Co-authored-by: mecatl <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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]