You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
everything: evict idle Streamable HTTP and SSE sessions #5558
server-everything's Streamable HTTP transport keeps one NodeStreamableHTTPServerTransport (and one server instance) per session in a Map keyed by session id (src/everything/transports/streamableHttp.ts), and the deprecated HTTP+SSE transport does the same (src/everything/transports/sse.ts). A session is removed only when its client closes it, so sessions that are initialized and then abandoned stay in memory for the life of the process. Opening many sessions grows memory roughly linearly (about 0.2 MiB per session in a local test), with no bound.
This is not a security issue for this server: it is a test server for client developers, binds loopback by default, and documents that it has no authentication. It is still a resource leak that a long-running test instance can hit.
Expected behavior
Idle sessions are evicted after a period of inactivity, and their transport and server instance are closed and cleaned up (timers, subscriptions, simulated-update intervals).
Approach
Track the last activity per session and evict sessions idle longer than a timeout, configurable through an environment variable with a sensible default (and possibly a maximum session count).
Apply the same to the SSE transport, since it shares the pattern.
The 2026-07-28 path is stateless and is not affected.
Document the setting in src/everything/README.md.
Acceptance criteria
A test shows an idle session evicted after the timeout and its resources released, while an active session survives.
Hi @cliffhall, thanks for opening this to track the fix!
I actually reported this exact behavior via a security advisory, though I completely understand the rationale for treating it as a resource leak rather than a security issue given the server's purpose.
For reference and to help verify the eventual fix, here are the numbers and the reproduction script I used during my analysis:
Memory growth: On a 128 MiB heap (--max-old-space-size=128), around 1,265 unclosed initialize requests are enough to trigger a V8 OOM abort (SIGABRT).
Affected path: Confirmed that the 2026-07-28 stateless path is unaffected, and the leak is isolated to the stateful session Map (and the equivalent SSE map).
Reproduction script (Node.js)
// Reproducer: the Everything Streamable HTTP transport keeps every 2025-era// session in an unbounded map. This script starts the built server with a small// heap, sends initialize POSTs, and shows that the process dies from heap// exhaustion instead of refusing or evicting sessions.//// Usage (from servers/):// npm run build -w src/everything// node repro_http_sessions.mjs//// Environment:// REPRO_HEAP=128 heap cap in MiB for the child// REPRO_LIMIT=3000 maximum initialize requests to send// REPRO_CONCURRENCY=50 requests in flight//// Exit code 0 means the bug reproduced (the child died before the limit);// 1 means it did not reproduce at this limit.import{spawn}from"node:child_process";import{randomInt}from"node:crypto";import{fileURLToPath}from"node:url";importpathfrom"node:path";constroot=path.resolve(path.dirname(fileURLToPath(import.meta.url)));constheapMiB=Number(process.env.REPRO_HEAP??128);constlimit=Number(process.env.REPRO_LIMIT??3000);constconcurrency=Number(process.env.REPRO_CONCURRENCY??50);constport=39000+randomInt(0,900);constchild=spawn(process.execPath,[`--max-old-space-size=${heapMiB}`,"src/everything/dist/index.js","streamableHttp"],{cwd: root,env: { ...process.env,PORT: String(port)},stdio: ["ignore","pipe","pipe"],},);letlog="";constkeep=(chunk)=>{log+=chunk.toString();if(log.length>64*1024)log=log.slice(-32*1024);};child.stdout.on("data",keep);child.stderr.on("data",keep);constsleep=(ms)=>newPromise((r)=>setTimeout(r,ms));asyncfunctionwaitForListening(timeoutMs=10_000){conststarted=Date.now();while(Date.now()-started<timeoutMs){if(log.includes("listening"))returntrue;if(child.exitCode!==null)returnfalse;awaitsleep(50);}returnfalse;}asyncfunctioninitialize(i){constresponse=awaitfetch(`http://127.0.0.1:${port}/mcp`,{method: "POST",headers: {"content-type": "application/json",accept: "application/json, text/event-stream",},body: JSON.stringify({jsonrpc: "2.0",id: i,method: "initialize",params: {protocolVersion: "2025-11-25",capabilities: {},clientInfo: {name: `repro-${i}`,version: "1"},},}),signal: AbortSignal.timeout(5_000),});constsession=response.headers.get("mcp-session-id");awaitresponse.body?.cancel();returnsession;}if(!(awaitwaitForListening())){console.error("server did not start:\n"+log);child.kill("SIGKILL");process.exit(2);}console.log(`server on ${port}, heap ${heapMiB} MiB, limit ${limit} sessions, concurrency ${concurrency}`,);letok=0;letfailed=0;constsessions=newSet();for(leti=1;i<=limit;i+=concurrency){if(child.exitCode!==null||child.signalCode!==null)break;constbatch=[];for(letk=0;k<concurrency&&i+k<=limit;k++){constid=i+k;batch.push(initialize(id).then((session)=>{if(session)sessions.add(session);ok++;}).catch(()=>{failed++;}),);}awaitPromise.all(batch);if(i%250===0){console.log(`sent ${i}: ok ${ok}, failed ${failed}, sessions ${sessions.size}`);}}// Give the OOM a moment to surface if it is in progress.awaitsleep(1_500);constdead=child.exitCode!==null||child.signalCode!==null;console.log(`result: ok ${ok}, failed ${failed}, unique sessions ${sessions.size}, alive ${!dead}`,);if(dead){console.log(`child exit code ${child.exitCode}, signal ${child.signalCode}`);console.log("last server output:\n"+log.split("\n").slice(-12).join("\n"));}else{child.kill("SIGKILL");}process.exit(dead ? 0 : 1);
When the fix is merged for v2.6.0, I'd really appreciate a quick shout-out or Reported-by credit in the commit/release notes. Thanks!
Activity
Pierpaolo1223 commentedon Nov 18, 2026
Hi @cliffhall, thanks for opening this to track the fix!
I actually reported this exact behavior via a security advisory, though I completely understand the rationale for treating it as a resource leak rather than a security issue given the server's purpose.
For reference and to help verify the eventual fix, here are the numbers and the reproduction script I used during my analysis:
128 MiBheap (--max-old-space-size=128), around 1,265 unclosedinitializerequests are enough to trigger a V8 OOM abort (SIGABRT).2026-07-28stateless path is unaffected, and the leak is isolated to the stateful sessionMap(and the equivalent SSE map).Reproduction script (Node.js)
When the fix is merged for
v2.6.0, I'd really appreciate a quick shout-out orReported-bycredit in the commit/release notes. Thanks!docs(everything): keep the README tables' form and link the reporter …
fix(everything): retry an idle session whose close failed