{"record":{"id":"849e10fc7b773658","repo":"different-ai/openwork","slug":"continuity-session","errorCode":"CONTINUITY_SESSION","errorMessage":"MCP session expired after initialize","messagePattern":"MCP session expired after initialize","errorType":"exception","errorClass":"ProbeFailure","httpStatus":null,"severity":"error","filePath":"packages/enterprise-mcp-mock-server/src/testing/probe.ts","lineNumber":786,"sourceCode":"    if (scenario.protocol.requireSession && !sessionId) {\n      throw new ProbeFailure(\"MCP_INITIALIZE\", \"mcp_initialize\", \"Initialize response omitted required MCP-Session-Id\")\n    }\n    recordPassed(phases, \"MCP_INITIALIZE\", startedAt, \"MCP version, capabilities, and session negotiated\")\n\n    const sessionHeaders = {\n      ...rpcHeaders,\n      \"mcp-session-id\": sessionId,\n      \"mcp-protocol-version\": initialize.protocolVersion,\n    }\n    startedAt = Date.now()\n    const initializedResponse = await fetchStep(mcpUrl, {\n      method: \"POST\",\n      headers: sessionHeaders,\n      body: JSON.stringify({ jsonrpc: \"2.0\", method: \"notifications/initialized\" }),\n    }, \"MCP_INITIALIZED\", overallDeadline)\n    await discardResponseBody(initializedResponse, \"MCP_INITIALIZED\", \"mcp_lifecycle\")\n    if (initializedResponse.status === 404) {\n      throw new ProbeFailure(\"CONTINUITY_SESSION\", \"mcp_session_expired\", \"MCP session expired after initialize\")\n    }\n    if (initializedResponse.status !== 202) {\n      throw new ProbeFailure(\"MCP_INITIALIZED\", \"mcp_lifecycle\", `Initialized notification returned HTTP ${initializedResponse.status}`)\n    }\n    recordPassed(phases, \"MCP_INITIALIZED\", startedAt, \"Initialized notification received HTTP 202\")\n\n    startedAt = Date.now()\n    const toolNames = new Set<string>()\n    const discoveredTools: MockTool[] = []\n    const cursors = new Set<string>()\n    let cursor: string | undefined\n    let catalogComplete = false\n    for (let page = 0; page < 25; page += 1) {\n      if (cursor) {\n        if (cursors.has(cursor)) throw new ProbeFailure(\"MCP_TOOL_DISCOVERY\", \"mcp_pagination_loop\", \"Tool catalog repeated a cursor\")\n        cursors.add(cursor)\n      }\n      const listRawResponse = await fetchStep(mcpUrl, {","sourceCodeStart":768,"sourceCodeEnd":804,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/packages/enterprise-mcp-mock-server/src/testing/probe.ts#L768-L804","documentation":"Thrown when the notifications/initialized POST (sent right after a successful initialize) returns HTTP 404. In streamable-HTTP MCP, a 404 on a post-initialize request signals the server no longer recognizes the session, so the probe classifies it as a session-expiry continuity failure rather than a generic lifecycle error.","triggerScenarios":"The server invalidates the session between initialize and notifications/initialized, or never persisted it, so the notification with the mcp-session-id header hits an unknown session and the server answers 404.","commonSituations":"In-memory session store lost between requests (multi-instance deployment without sticky routing/session affinity); very short session TTL; server restart during the probe; session store keyed incorrectly so the id never matches.","solutions":["Ensure the server persists sessions for the probe's lifetime (or long enough TTL)","Use sticky sessions / a shared session store when running multiple server instances","Verify the server routes on mcp-session-id exactly as issued during initialize","Retry the probe against a single warm server instance to rule out restarts"],"exampleFix":"// before (server)\nconst session = sessions.get(req.headers[\"mcp-session-id\"]) ?? null // 404 if lost\n// after (server)\npersistSessionInSharedStore(sessionId, session) // e.g. Redis","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await probeEnterpriseMcpMockServer(scenario)\n} catch (e) {\n  if (e instanceof ProbeFailure && e.code === \"CONTINUITY_SESSION\") {\n    console.error(\"Session expired mid-probe:\", e.message) // re-init or use sticky sessions\n  }\n}","preventionTips":["Use sticky sessions or a shared session store across server instances","Set session TTL comfortably above probe duration","Avoid server restarts during probe runs"],"tags":["mcp","session-expired","http-404","continuity"],"backgroundTag":"session-expired","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}