decolua/9router · error

[${res.status}] ${text}

Error message

[${res.status}] ${text}

What it means

Trae's executor first creates a chat session via a POST; createSession() treats a non-2xx response as fatal and throws this error embedding the status code and the raw response body. The library surfaces the body verbatim because Trae error pages/JSON usually contain the real cause (auth, quota, region).

Source

Thrown at open-sse/executors/trae.js:128

        content: [],
        query,
        model_name: modelName,
        agent_type: "solo_agent_remote",
        model_selection_strategy: strategy,
        common_params: this.commonParams(psd, mode),
      },
      env: "remote",
      auto_create_project: false,
      origin: "web",
    };
    const res = await proxyAwareFetch(`${this.base()}/chat_sessions`, {
      method: "POST",
      headers,
      body: JSON.stringify(body),
      signal,
    }, null);
    const text = await res.text();
    if (!res.ok) throw new Error(`[${res.status}] ${text}`);
    const json = JSON.parse(text);
    if (json?.code !== 0) throw new Error(`Trae create_session: ${JSON.stringify(json)}`);
    return { sessionId: json.data.chat_session_id, messageId: json.data.message_id };
  }

  // GET /events SSE → invoke onEvent(eventType, dataObj) per frame.
  // Resolves when `done`/`error` arrives, the stream ends, or timeout fires.
  async streamEvents(headers, sessionId, replyTo, onEvent, signal) {
    const url = `${this.base()}/chat_sessions/${sessionId}/events?reply_to_message_id=${encodeURIComponent(replyTo)}`;
    const ctrl = new AbortController();
    if (signal?.aborted) ctrl.abort();
    const timer = setTimeout(() => ctrl.abort(new Error("trae stream timeout")), STREAM_TIMEOUT_MS);
    const onAbort = () => ctrl.abort();
    if (signal) signal.addEventListener("abort", onAbort, { once: true });
    try {
      const res = await proxyAwareFetch(url, { method: "GET", headers, signal: ctrl.signal }, null);
      if (!res.ok || !res.body) throw new Error(`[${res.status}] events stream failed`);
      const reader = res.body.getReader();

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Read the body in the message — 401/403 → refresh or re-authenticate the Trae credential; 429 → back off; 5xx → retry later
  2. Re-authenticate the Trae account (token refresh or manual re-login) if auth expired
  3. Retry the request; transient 5xx/network errors often clear
  4. Bypass or reconfigure proxies that may return interception pages
  5. Update 9router in case Trae changed its session endpoint contract
  6. Implement account fallback so a failing Trae credential is skipped automatically

Example fix

// before
const s = await executor.createSession(...); // throws raw
// after
let s;
try { s = await executor.createSession(...); }
catch (e) {
  if (/\[40[13]\]/.test(e.message)) { await refreshTraeCredential(); s = await executor.createSession(...); }
  else throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

// pre-check credential validity before creating a session
const cred = await getTraeCredential();
if (!cred || Date.now() > (cred.expiresAt ?? Infinity)) {
  await refreshTraeCredential();
}

Try / catch

try {
  session = await executor.createSession(...);
} catch (e) {
  const status = +String(e.message).match(/^\[(\d+)\]/)?.[1] ?? 0;
  if (status === 401 || status === 403) { await refreshTraeCredential(); return retry(); }
  if (status === 429) { await sleep(backoff); return retry(); }
  if (status >= 500) { return retryWithBackoff(); }
  throw e;
}

Prevention

When it happens

Trigger: The Trae create-session endpoint returns an HTTP error status: expired/invalid auth token (401/403), rate limit (429), server error (5xx), or a proxy interception page (403/502). Raised from createSession, called by execute.

Common situations: Trae credential expired and needs re-login/refresh; account quota exhausted; Trae blocking the datacenter IP or requiring a different region endpoint; a corporate proxy returning an error page.

Related errors


AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30). Data as JSON: /api/errors/43cc2df38cb735d2. Report an issue: GitHub.