{"record":{"id":"1a48b13044866e10","repo":"diegosouzapw/OmniRoute","slug":"res-status-events-stream-failed","errorCode":null,"errorMessage":"[${res.status}] events stream failed","messagePattern":"\\[(.+?)\\] events stream failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"open-sse/executors/trae.ts","lineNumber":181,"sourceCode":"   */\n  private async streamEvents(\n    headers: Record<string, string>,\n    sessionId: string,\n    replyTo: string,\n    onEvent: (ev: string | null, data: JsonRecord) => boolean,\n    signal?: AbortSignal | null\n  ): Promise<void> {\n    const url = `${this.base()}/chat_sessions/${sessionId}/events?reply_to_message_id=${encodeURIComponent(replyTo)}`;\n    const ctrl = new AbortController();\n    // If the caller's signal is already aborted, abort upfront so we don't open\n    // a network request the consumer no longer wants.\n    if (signal?.aborted) ctrl.abort();\n    const timer = setTimeout(() => ctrl.abort(new Error(\"trae stream timeout\")), STREAM_TIMEOUT_MS);\n    const onAbort = () => ctrl.abort();\n    if (signal) signal.addEventListener(\"abort\", onAbort, { once: true });\n    try {\n      const res = await fetch(url, { method: \"GET\", headers, signal: ctrl.signal });\n      if (!res.ok || !res.body) throw new Error(`[${res.status}] events stream failed`);\n      const reader = res.body.getReader();\n      const decoder = new TextDecoder();\n      let buf = \"\";\n      let ev: string | null = null;\n      for (;;) {\n        const { done, value } = await reader.read();\n        if (done) break;\n        buf += decoder.decode(value, { stream: true });\n        let nl: number;\n        // SSE frames are separated by lines; process complete lines only.\n        while ((nl = buf.indexOf(\"\\n\")) >= 0) {\n          const line = buf.slice(0, nl).replace(/\\r$/, \"\");\n          buf = buf.slice(nl + 1);\n          if (line.startsWith(\"event:\")) ev = line.slice(6).trim();\n          else if (line.startsWith(\"data:\")) {\n            const payload = line.slice(5).trim();\n            let data: JsonRecord;\n            try {","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/open-sse/executors/trae.ts#L163-L199","documentation":"Error \"[${res.status}] events stream failed\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at open-sse/executors/trae.ts:181 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}