BabylonJS/Babylon.js · error

Session ${parsed} does not exist. No active sessions.

Error message

Session ${parsed} does not exist. No active sessions.

What it means

ValidateSessionId throws this variant when the requested numeric id is not found and the bridge reports zero active sessions, making it clear the problem is no sessions existing at all rather than a wrong id.

Source

Thrown at packages/dev/inspector-v2/src/cli/cli.ts:247

        socket.close();
    }
}

/**
 * Parses and validates an explicit session id string against the list of active sessions.
 * @param explicitId The session id string to validate.
 * @param sessions The list of active sessions from the bridge.
 * @returns The matching session info.
 */
export function ValidateSessionId(explicitId: string, sessions: SessionInfo[]): SessionInfo {
    const parsed = parseInt(explicitId, 10);
    if (isNaN(parsed)) {
        throw new Error("Session id must be a number.");
    }
    const match = sessions.find((s) => s.id === parsed);
    if (!match) {
        if (sessions.length === 0) {
            throw new Error(`Session ${parsed} does not exist. No active sessions.`);
        }
        const list = sessions.map((s) => `  [${s.id}] ${s.name}`).join("\n");
        throw new Error(`Session ${parsed} does not exist. Active sessions:\n${list}`);
    }
    return match;
}

/**
 * Resolves and validates the session id. Requires an explicit session id
 * provided via `--session <id>`. Throws if the id is missing, non-numeric,
 * or does not match an active session.
 * @param socket The WebSocket connection to the bridge.
 * @param explicitId The session id string from --session.
 * @returns The validated numeric session id.
 */
export async function ResolveSessionId(socket: WebSocket, explicitId: string | undefined): Promise<number> {
    if (explicitId === undefined) {
        throw new Error("A session id is required. Use --session to list active sessions, then pass --session <id>.");

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Open a page with the inspector bridge running so at least one session is active, then retry the command.
  2. Re-list sessions to get fresh ids after a page reload (ids change on reconnect).
  3. Check that the bridge WebSocket connection is alive and the app actually injected the bridge script.
  4. Automate with a readiness check: poll the sessions list until non-empty before issuing commands.

Example fix

// before
cli inspect --session 3   # no sessions connected
// after
# start the app/page with the bridge first, then:
cli sessions              # -> [1] MyPage
cli inspect --session 1
Defensive patterns

Strategy: validation

Validate before calling

async function hasActiveSessions(socket: WebSocket): Promise<boolean> {
  const res = await SendAndReceive<SessionsResponse>(socket, { type: "sessions" });
  return res.sessions.length > 0;
}

Try / catch

try {
  const s = ValidateSessionId(id, sessions);
} catch (e) {
  if (e instanceof Error && e.message.includes("No active sessions")) {
    console.error("No inspector sessions connected. Open the app page with the bridge enabled first.");
  } else throw e;
}

Prevention

When it happens

Trigger: Passing --session <n> when no Babylon page/bridge session is currently connected — e.g. the target tab was closed, the bridge restarted, or the CLI was run before opening any inspector-enabled page.

Common situations: Running scripted CLI commands against a browser tab that has since been reloaded or closed; starting the CLI before launching the app; bridge server restarted and session ids invalidated.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/2e13c459c0bd6886. Report an issue: GitHub.