BabylonJS/Babylon.js · error
Session ${parsed} does not exist. Active sessions: ${list}
Error message
Session ${parsed} does not exist. Active sessions:
${list} What it means
ValidateSessionId throws this variant when the numeric id does not match any active session, and at least one other session exists. The message enumerates the available ids/names so the caller can pick a valid one.
Source
Thrown at packages/dev/inspector-v2/src/cli/cli.ts:250
/**
* 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>.");
}
const response = await SendAndReceive<SessionsResponse>(socket, { type: "sessions" });
View on GitHub (pinned to 0592b347b8)
Solutions
- Use the id list printed in the error (or run the sessions command) and pass one of the currently listed ids.
- Re-fetch session ids each run instead of hardcoding them in scripts.
- If multiple tabs are open, target the correct one by matching s.name against the listed session names.
Example fix
// before cli inspect --session 7 # stale id // after # error lists: [1] TabA, [2] TabB cli inspect --session 2
Defensive patterns
Strategy: validation
Validate before calling
function sessionExists(sessions: SessionInfo[], id: number): boolean {
return sessions.some((s) => s.id === id);
}
if (!sessionExists(sessions, parsed)) {
console.error(`Unknown id ${parsed}. Available: ${sessions.map((s) => s.id).join(", ")}`);
} Try / catch
try {
const s = ValidateSessionId(id, sessions);
} catch (e) {
if (e instanceof Error && e.message.includes("does not exist. Active sessions:")) {
console.error(e.message); // shows valid ids to pick from
} else throw e;
} Prevention
- Fetch fresh ids each run; never hardcode session ids in scripts
- Match sessions by name when multiple tabs are open
- Re-resolve ids after any page reload or bridge restart
When it happens
Trigger: Passing --session <n> with an id that is stale (page reloaded, bridge restarted and ids reassigned) or simply wrong while other sessions are live.
Common situations: Reusing a session id from an earlier run in a script; multiple tabs open and targeting the wrong id; ids shifted after some sessions disconnected.
Related errors
- Session id must be a number.
- Session ${parsed} does not exist. No active sessions.
- A session id is required. Use --session to list active sessi
- Sample2DRgbaToRef: widthPx and heightPx must be positive.
- At least one mesh is needed to create the nav mesh.
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/d16fa1767ab041d8.
Report an issue: GitHub.