diegosouzapw/OmniRoute · error
SESSION_LIMIT_EXCEEDED
SESSION_LIMIT_EXCEEDED
Error message
You have reached the maximum number of active sessions (${maxSessions}). Please close unused sessions or wait for them to expire. What it means
checkSessionLimit (T08): the API key already has maxSessions active sessions (limit from the DB, 0 = unlimited), so admitting another would exceed the per-key concurrency cap. Returns a SESSION_LIMIT_EXCEEDED object rendered as a 429; it is a quota validation, not a fault.
Solutions
- Close unused sessions for this API key or wait for them to expire
- Raise the key's max_sessions setting if the limit is too low
- Use a different API key for additional concurrent sessions
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at open-sse/services/sessionManager.ts:312 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/d34b7d56bc6b60d8.
Report an issue: GitHub.
Appendix: source
Thrown at open-sse/services/sessionManager.ts:312
}
}
/**
* T08: Check whether adding a new session would exceed the key's max_sessions limit.
* Returns null if allowed, or an error object to return as a 429 response.
*
* @param apiKeyId - The API key's UUID
* @param maxSessions - The limit from the DB (0 = unlimited)
*/
export function checkSessionLimit(
apiKeyId: string,
maxSessions: number
): { code: "SESSION_LIMIT_EXCEEDED"; message: string; limit: number; current: number } | null {
if (!maxSessions || maxSessions <= 0) return null; // unlimited
const current = getActiveSessionCountForKey(apiKeyId);
if (current < maxSessions) return null;
return {
code: "SESSION_LIMIT_EXCEEDED",
message:
`You have reached the maximum number of active sessions (${maxSessions}). ` +
`Please close unused sessions or wait for them to expire.`,
limit: maxSessions,
current,
};
}
/**
* T04: Extract an external session ID from request headers.
* Accepts both hyphenated and underscore forms for Nginx compatibility.
* Nginx drops headers with underscores by default — use `underscores_in_headers on`
* in nginx.conf, or use X-Session-Id (hyphenated) which passes cleanly.
*
* Ref: sub2api README + PR #634
*
* @param headers - Request headers (Headers object or plain object with .get())
* @returns External session ID with "ext:" prefix, or nullView on GitHub (pinned to a179ffed5b)