diegosouzapw/OmniRoute · error · Error

Amelia init failed

Error message

Amelia init failed: ${res.status}

What it means

AmeliaClient.init() got a non-2xx HTTP status from the Amelia web-client bootstrap endpoint (GET `${BASE_URL}/Amelia/api/init`), so the session/WebSocket handshake never started. The status code is interpolated into the message. Typically the site is up but rejecting the synthetic browser request (bot protection such as Cloudflare, stale User-Agent/Origin headers) or the Amelia service is temporarily unavailable — a transient upstream condition, not a code defect.

Solutions

  1. Retry init after a short backoff — transient 5xx/bot-protection responses often clear on the next request
  2. Update the User-Agent, Origin and Referer headers to match a current real browser; a stale Chrome version string is a common trigger
  3. Check whether BASE_URL is still the correct Amelia host and that the service is reachable outside the proxy
  4. If the provider keeps failing, rotate to another Amelia connection or let combo routing fall back to a different provider
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at open-sse/executors/chipotle.ts:46 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/2c7e467a5f07ef1c. Report an issue: GitHub.

Appendix: source

Thrown at open-sse/executors/chipotle.ts:46

class AmeliaClient {
  private session: AmeliaSession | null = null;
  private ws: import("ws").WebSocket | null = null;
  private stompConnected = false;
  private messageCallbacks: Map<string, (msg: string) => void> = new Map();
  private connectPromise: Promise<void> | null = null;

  async init(): Promise<void> {
    const res = await fetch(`${BASE_URL}/Amelia/api/init`, {
      headers: {
        "User-Agent":
          "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36",
        Origin: BASE_URL,
        Referer: `${BASE_URL}/Amelia/ui/chipotle/chat?embed=iframe`,
      },
      redirect: "manual",
    });

    if (!res.ok) throw new Error(`Amelia init failed: ${res.status}`);

    const data = (await res.json()) as {
      csrfToken: string;
      user: { userId: string; anonymous: boolean };
    };

    const setCookies = res.headers.getSetCookie?.() ?? [];
    const cookieHeader = setCookies.map((c) => c.split(";")[0]).join("; ");

    this.session = {
      csrfToken: data.csrfToken,
      userId: data.user.userId,
      cookieHeader,
    };
  }

  async connect(): Promise<void> {
    if (!this.session) throw new Error("Call init() first");

View on GitHub (pinned to a179ffed5b)