Repository navigation
fix(subscriptions): stop retrying a subscriptions/listen refused over HTTP - #2730
Merged
Merged
Conversation
… HTTP A modern-era subscriptions/listen refused with a bare 403 (or a 400, 404 or 405) was handed to the reconnect machinery as though it were a drop, re-sent at the backoff until the eight-attempt cap and never reported. The refused URI's rollback also cleared the badge's `active` gate, so the refusal showed nowhere. Classify the rejection by the HTTP status on the SDK's generic ClientHttpNotImplemented error (auth-coded 401/403s never carry that code), settle the stream on a new "refused" status carrying the status, and surface it in the web Subscriptions section and the TUI pane whatever the subscription count. Transient statuses (5xx, 408, 429) keep retrying. Adds a refuseSubscriptionsListen test-server option and the subscriptions-listen-refused-http showcase. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: cliffhall <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The scoped refusal handling and regression coverage address the reported issue without identified blocking defects.
No open issues 🎉
What changed in this PR
Fixes #2722 by stopping automatic retries after deterministic HTTP refusals of subscriptions/listen and displaying the reason even when no subscriptions remain.
Changes:
- Classifies HTTP 400/403/404/405 refusals while preserving transient-error retries and auth handling.
- Adds refusal status and explanations to Web and TUI.
- Adds regression coverage and a configurable test-server showcase.
| File | Description |
|---|---|
test-servers/src/test-server-http.ts |
Injects configured HTTP listen refusals. |
test-servers/src/load-config.ts |
Adds the refusal configuration field. |
test-servers/src/composable-test-server.ts |
Defines and documents the refusal option. |
test-servers/configs/subscriptions-listen-refused-http.json |
Provides a 403 showcase. |
docs/test-servers.md |
Documents reproduction and expected behavior. |
core/mcp/types.ts |
Defines refusal status and HTTP details. |
core/mcp/subscriptionRefusal.ts |
Classifies refusals and formats explanations. |
core/mcp/inspectorClient.ts |
Records refusals and stops reconnect attempts. |
clients/web/src/test/integration/mcp/inspectorClient-subscriptions-era.test.ts |
Covers refusal, rollback, retry, and reset behavior. |
clients/web/src/test/core/mcp/subscriptionRefusal.test.ts |
Tests classification and messages. |
clients/web/src/components/groups/ResourceControls/ResourceControls.tsx |
Shows refusals in empty subscription sections. |
clients/web/src/components/groups/ResourceControls/ResourceControls.test.tsx |
Tests notice visibility and legacy exclusion. |
clients/web/src/components/elements/SubscriptionStreamBadge/subscriptionStreamUtils.ts |
Adds refusal badge presentation. |
clients/web/src/components/elements/SubscriptionStreamBadge/SubscriptionStreamBadge.test.tsx |
Tests refusal badge and tooltip. |
clients/web/src/components/elements/SubscriptionStreamBadge/SubscriptionStreamBadge.stories.tsx |
Adds a refused-state story. |
clients/tui/src/components/SubscriptionsTab.tsx |
Displays inactive-stream refusals. |
clients/tui/__tests__/SubscriptionsTab.test.tsx |
Tests TUI refusal visibility. |
Review effort: Balanced
Member
Author
|
Copilot review loop closed: round 1 was clean ("No open issues", no inline comments, no suppressed comments), so per the pr-flow exit rule no further round was requested. |
This was referenced Oct 20, 2026
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.
Closes #2722
Problem
On a modern-era server, a
subscriptions/listenrefused with a bare HTTP 403 was re-sent at the reconnect backoff until the eight-attempt cap and never reported. The refused URI's rollback also cleared theactiveflag the badge is gated on, so the refusal showed nowhere.Change
core/mcp/subscriptionRefusal.ts(new) classifies a rejectedlisten()as a deterministic refusal when it is anSdkHttpErrorwith the SDK's genericClientHttpNotImplementedcode and status 400, 403, 404 or 405. The code check is what keeps auth failures out: a 401, and a 403 carryinginsufficient_scope, go through the auth flow and surface under the SDK's auth codes. 5xx, 408, 429, network errors and timeouts stay retryable.InspectorClientrecords the refusal at the rejection site, under the same generation gate as Modern subscriptions: say "the server closed the subscription without acknowledging it" instead of silently retrying eight times #2097'smodernNeverAcknowledged. Both failure handlers then settle on a new"refused"stream status that carriesrefusal: { status, statusText }, with no reconnect. The refusal is reported ahead of the empty-filter check, so it survives a rollback that empties the filter.Subscriptions (0)can be opened to read it.Listen stream: refused by the serverand the same sentence, shown while the stream is inactive.transport.modern.refuseSubscriptionsListen: <status>option, and asubscriptions-listen-refused-http.jsonshowcase (documented indocs/test-servers.md).Tests
inspectorClient-subscriptions-era.test.ts, 10 new) against the real refusing server for 403/400/404/405: one listen, therefusedstate with the HTTP status, on subscribe and on connect, and when the rollback empties the filter. Some tests stublisten()with theSdkHttpErrorthe web remote transport rebuilds (Web client: protocol era "auto" does not fall back to legacy when a 2025-only server rejects the probe with HTTP 400 #2660), because the Node transport also firesonerroron a failed POST, which already makes the clienterrorand stops the timer. Those tests prove that a refusal is not retried while the session stays connected, that a 503 still is, and that a reconnect run ends at the first refusal.ResourceControlsnotice (modern era only), and the TUI pane.npm run local:gatepassed.Screenshots
subscriptions-listen-refused-http.json, Protocol Era = Modern, after clicking Subscribe onresource_1. The Monitor sidebar width was seeded by the capture script.Before: the listen is re-sent at the backoff, and nothing explains the empty
Subscriptions (0):After, on connect: the connect-time listen is refused once, and the badge says so:
After Subscribe: one further listen, no retries:
The notice, with the section opened:
The
PENDINGlisten rows in the Protocol tab are #2721, a separate issue.Deliberately out of scope
Retry-Afteron 429/503 ("consider" in the issue). Transient statuses keep the existing backoff.SdkHttpError, so it stays retryable, as Modern subscriptions: say "the server closed the subscription without acknowledging it" instead of silently retrying eight times #2097 left "a pre-ack error response".subscriptionFailureMessagealso wraps legacyresources/subscribefailures, where "refused subscriptions/listen" would be wrong, so the explanation lives on the stream state instead.errorthroughonerror. That is pre-existing and unchanged here.🤖 Generated with Claude Code