fix(sdk): deterministic session IDs across server instances#8
Merged
johannmachemer merged 2 commits intomainfrom Feb 27, 2026
Merged
fix(sdk): deterministic session IDs across server instances#8johannmachemer merged 2 commits intomainfrom
johannmachemer merged 2 commits intomainfrom
Conversation
Replace the in-memory globalSessionMap with deterministic session ID derivation using SHA-256 hashing of the MCP session key. This ensures that different server instances processing the same MCP session produce the same Yavio session ID without requiring shared state. - Add deriveSessionId() to ids.ts (SHA-256 → base64url, truncated to 21 chars) - Remove globalSessionMap, MAX_SESSION_MAP_SIZE, and LRU eviction logic - Simplify getSession() → resolveSession() (direct derivation, no map lookup) - Rename _resetSessionMap → _resetGlobalState (only clears dedup sets) - Replace eviction test with cross-instance stability test
Coverage Report for sdk
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
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.
Summary
globalSessionMapwith deterministic session ID derivation using SHA-256 hashing of the MCP session key — any server instance processing the same MCP session now produces the same Yavio session ID without shared statederiveSessionId()toids.ts(SHA-256 → base64url, truncated to 21 chars, matchingses_prefix format)globalSessionMap,MAX_SESSION_MAP_SIZE, and LRU eviction logic that only worked within a single processgetSession()→resolveSession()— direct derivation instead of map lookupTest plan
deriveSessionIdunit tests (prefix, length, determinism, uniqueness, URL-safe chars)