[vMCP] Handle backend session expiration with automatic re-initialization
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2.2k
- Forks
- 300
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 184
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the vMCP backend operation path, the client map and backend session ID map, and the existing isSessionExpiredError handling. Trace how reinitializeBackend should acquire locks and use singleflight, then add unit coverage for successful retry, double failure, and concurrent deduplication. Done means one re-initialization and one retry preserve the vMCP session, while a second failure returns immediately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100