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

Error "You have reached the maximum number of active sessions (${maxSessions}). Please close unused sessions or wait for them to expire." thrown in diegosouzapw/OmniRoute.

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 null

View on GitHub (pinned to a179ffed5b)

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.