sgl-project/sglang · error · Error

This browser does not support gzip stream decoding

Error message

This browser does not support gzip stream decoding

What it means

Thrown by ngram_corpus Param::parse after the range parses: the numeric bounds must satisfy L <= R and R <= 128. Violating either (inverted range or upper bound beyond the hard cap of 128 positions) raises this error.

Source

Thrown at python/sglang/multimodal_gen/apps/realtime_webui/app.js:1063

  const count = Number(header.num_frames);
  const frameBytes = Number(header.bytes_per_frame);
  const src = payload instanceof Uint8Array ? payload : new Uint8Array(payload);
  const items = [];
  for (let f = 0; f < count; f++) {
    const offset = f * frameBytes;
    const imageBytes = new Uint8ClampedArray(
      src.buffer,
      src.byteOffset + offset,
      frameBytes,
    );
    items.push({ image: new ImageData(imageBytes, width, height), chunk: header.chunk_index });
  }
  return items;
}

async function gunzipBytes(payload) {
  if (typeof DecompressionStream === "undefined") {
    throw new Error("This browser does not support gzip stream decoding");
  }
  const stream = new Blob([payload]).stream().pipeThrough(new DecompressionStream("gzip"));
  return new Uint8Array(await new Response(stream).arrayBuffer());
}

async function restoreDeltaGzipRawRgb(header, payload) {
  const frameBytes = Number(header.bytes_per_frame);
  const count = Number(header.num_frames);
  const expectedSize = frameBytes * count;
  const restored = await gunzipBytes(payload);
  if (restored.length !== expectedSize) {
    throw new Error(`delta payload size mismatch: expected ${expectedSize}, got ${restored.length}`);
  }
  let previous = header.delta_reference === "previous-frame" ? lastRawRgbFrame : null;
  if (header.delta_reference === "previous-frame" && !previous) {
    throw new Error("Missing previous frame for delta payload");
  }
  for (let f = 0; f < count; f++) {

View on GitHub (pinned to 0132848349)

Solutions

  1. Clamp ranges to 0..128 and ensure L <= R, e.g. '2-128|8'
  2. If you need R > 128 you must modify the C++ cap and rebuild — it is a hard limit
  3. Ensure range tokens are plain decimal integers so atoi parses them as intended

Example fix

# before
param.resetBatchReturnTokenNum("4-200|3")

# after
param.resetBatchReturnTokenNum("4-128|3")
Defensive patterns

Strategy: validation

Validate before calling

for s in cfg.split():
    (l, r), v = map(int, s.replace("|", "-").split("-")), 0
    l, r = (int(x) for x in s.split("|")[0].split("-"))
    assert 0 <= l <= r <= 128, f"range out of bounds in {s!r}"

Type guard

def ranges_in_bounds(cfg: str) -> bool:
    for s in cfg.split():
        l, r = (int(x) for x in s.split("|")[0].split("-"))
        if not (0 <= l <= r <= 128):
            return False
    return True

Try / catch

try:
    param.resetBatchReturnTokenNum(cfg)
except RuntimeError as e:
    if "invalid range" in str(e):
        raise ValueError("ngram ranges must satisfy L<=R<=128") from e
    raise

Prevention

When it happens

Trigger: resetBatchReturnTokenNum with a segment like '8-2|3' (L > R) or '4-200|3' (R > 128). Note atoi is used, so non-numeric junk silently becomes 0 and can also surface as an inverted range.

Common situations: Copying a config tuned for another implementation that allows longer histories, off-by-one when computing R from a window length, or non-numeric tokens silently parsing to 0 via atoi.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/04e80c407bd60f25. Report an issue: GitHub.