-
Notifications
You must be signed in to change notification settings - Fork 181
Open
Open
Copy link
Labels
enhancementNew feature or requestNew feature or requestgoPull requests that update go codePull requests that update go codep1MediumMediumvmcpVirtual MCP Server related issuesVirtual MCP Server related issues
Description
Depends on #3865
When a backend returns a session-expired error (HTTP 404 or "session not found"), the vMCP session should automatically re-initialize the backend client and retry the operation once, preserving the vMCP session from the client's perspective.
Implementation:
- Detect
isSessionExpiredError(err)after the initial call reinitializeBackend: acquire write lock, close old client, create new client (triggers newInitializeRequesthandshake), update client map and backend session ID map- Re-read the updated client under
RLockafter re-initialization - Retry the operation exactly once; if it fails again, return the error immediately
- Use
singleflightto deduplicate concurrent expiration detections for the same backend
Acceptance Criteria
- A backend session-expired error triggers automatic re-initialization of that backend client
- The operation is retried exactly once with the new client
- A second consecutive failure is returned to the caller immediately (no further retries)
- Both the initial and post-reinit reads from the client map are protected by
RLock -
reinitializeBackendholds the write lock while replacing the client - Concurrent expiration detections for the same backend result in only one re-initialization (via
singleflight) - The vMCP session is unaffected by backend session expiration from the client's perspective
- Unit tests cover: successful retry, double failure, concurrent detections deduplicated
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgoPull requests that update go codePull requests that update go codep1MediumMediumvmcpVirtual MCP Server related issuesVirtual MCP Server related issues