decolua/9router · error

AWS EventStream contains duplicate header: ${name}

Error message

AWS EventStream contains duplicate header: ${name}

What it means

While decoding an AWS EventStream frame's header section, parseEventFrame() tracks every header name it has seen in a Set. AWS EventStream headers are a map, so a repeated name means the frame violates the protocol and its content is ambiguous; the parser throws immediately instead of silently letting a later value overwrite an earlier one.

Source

Thrown at open-sse/executors/kiro.js:1234

  }

  const headers = Object.create(null);
  const names = new Set();
  let offset = 12;
  const headerEnd = offset + headersLength;
  const requireBytes = (count) => {
    if (offset + count > headerEnd) {
      throw new Error("AWS EventStream header exceeds its declared bounds");
    }
  };

  while (offset < headerEnd) {
    requireBytes(1);
    const nameLength = data[offset++];
    requireBytes(nameLength + 1);
    const name = decoder.decode(data.subarray(offset, offset + nameLength));
    offset += nameLength;
    if (names.has(name)) throw new Error(`AWS EventStream contains duplicate header: ${name}`);
    names.add(name);
    const type = data[offset++];

    if (type === 0 || type === 1) {
      headers[name] = type === 0;
    } else if (type === 2) {
      requireBytes(1);
      headers[name] = view.getInt8(offset);
      offset += 1;
    } else if (type === 3) {
      requireBytes(2);
      headers[name] = view.getInt16(offset, false);
      offset += 2;
    } else if (type === 4) {
      requireBytes(4);
      headers[name] = view.getInt32(offset, false);
      offset += 4;
    } else if (type === 5 || type === 8) {

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Update 9router to the latest version to pick up any parser fixes for the current Kiro wire format
  2. Bypass or remove intermediaries (proxies, logging middlewares) that may corrupt the binary stream
  3. Retry the request — a single corrupted frame in a long stream is usually transient
  4. Log the offending frame (hex/base64) and verify the header section against the AWS EventStream spec to confirm upstream duplication
  5. If reproducible per-account, re-authenticate or switch accounts in case a specific backend node is emitting bad frames
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await executor.execute(req);
} catch (e) {
  if (String(e.message).includes('duplicate header')) {
    return retryOrFallback(req, 'eventstream-duplicate-header');
  }
  throw e;
}

Prevention

When it happens

Trigger: The bytes of a frame's header section decode to two entries with the same header name. Produced by corrupted/truncated binary data, a frame re-assembled from the wrong byte offsets, or an upstream bug emitting duplicated headers.

Common situations: Middlebox/proxy mangling the binary Kiro stream; protocol drift after a Kiro upstream update; reading frames with a stale parser version after the wire format gained new header entries.

Related errors


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