diegosouzapw/OmniRoute · error

[codex] finishStream: failed to enqueue [DONE]

Error message

[codex] finishStream: failed to enqueue [DONE]

What it means

finishStream attempted to enqueue the terminal 'data: [DONE]' SSE marker into the downstream ReadableStream but the controller rejected it — typically because the consumer already cancelled or the stream is already closed. The stream ends without the explicit DONE marker; well-behaved clients treating close as end-of-stream are unaffected.

Solutions

  1. No data loss — request output was already delivered
  2. Check whether clients abort prematurely if DONE markers matter to them
  3. Ignore unless clients hang waiting for an explicit DONE
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at open-sse/executors/codex.ts:942 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/6a98b845b0229e97. Report an issue: GitHub.

Appendix: source

Thrown at open-sse/executors/codex.ts:942

      closeSocket = true,
    }: {
      reason: string;
      emitDone?: boolean;
      closeController?: boolean;
      closeSocket?: boolean;
    }) => {
      if (closed) return;
      closed = true;
      removeAbortListener();
      if (closeSocket) closeUpstream(reason);

      const controller = streamController;
      if (!controller || !closeController) return;
      if (emitDone) {
        try {
          controller.enqueue(encoder.encode("data: [DONE]\n\n"));
        } catch {
          console.warn("[codex] finishStream: failed to enqueue [DONE]");
          // The downstream may already have gone away.
        }
      }
      try {
        controller.close();
      } catch {
        console.warn("[codex] finishStream: failed to close controller");
        // The controller may already be closed.
      }
    };

    const failController = (code: string, message: string) => {
      if (closed) return;
      const controller = streamController;
      const payload = JSON.stringify({
        type: "response.failed",
        response: {
          id: null,

View on GitHub (pinned to a179ffed5b)