Skip to content

Compression Error : ZlibError #1656

Open

Description

@K-Shivam-Rao

What happened

An error occasionally appears after a task has completed successfully. This issue seems to occur more frequently after a long session.

Steps to reproduce

  1. Start a task.
  2. Allow the task to run until it completes successfully.
  3. Continue working in the application for an extended period.
  4. Observe whether an error appears after the task finishes.

Where does this happen?

CLI (terminal client)

Operating system

Windows

Version

0.2.36

Model

DeepSeek V4.1 Flash Fast

Logs or screenshots

Activity

  1. added
    type:bug
    on Nov 13, 2026
  2. mahdijon5080-tech commented on Nov 13, 2026

    @mahdijon5080-tech

    سلام، بعد از یک قطعی کوتاه اینترنت، در Freebuff Desktop 0.0.202 دیگر هیچ ابزار لوکالی برای جلسه ثبت نمیشود. پروژه روی Local است و composer هم Local نشان میدهد، ولی در هر پیام agent میگوید کامپیوتر در دسترس نیست و ابزارهایی مثل خواندن فایل و ترمینال اصلاً در جلسه وجود ندارند (خطای «not available» میدهند، نه timeout). سیستم روشن و در حال استفاده است، اینترنت پایدار است و VPN هم ندارم. بستن کامل برنامه، باز کردن چت جدید و ریاستارت سیستم را امتحان کردهام و فایدهای نداشته. لطفاً راهنمایی کنید چطور اتصال ابزارهای لوکال (machine binding) را ریست کنم.

  3. added
    area:cli
    bot:triaged
    needs-info
    on Nov 13, 2026
  4. lukew2580 commented on Nov 16, 2026

    @lukew2580

    Not with the team — I'm a community member helping triage this backlog, and this one reproduces without needing a real long session.

    The result first: the trigger is an unfinished gzip stream at the end of the response body, not a dropped connection. The chat-completions response is gzipped SSE, and when the HTTP body ends before the gzip stream itself is finished, Bun's fetch throws ZlibError fetching <url> — even when the connection closed politely. That is why the error can land after a turn has visibly finished: the events have already been decoded and rendered when the stream ends.

    Three things from you would settle the rest:

    1. Did the turn continue afterwards, or was it dead at that point?
    2. Did you see a message about Freebuff not confirming that the provider finished its response after several retries, or a bare ZlibError?
    3. Roughly how many turns into the session, and is a fresh session with the same prompt clean?

    The evidence for that first sentence, since it is a stronger claim than "a network blip":

    case bun 1.3.14 bun 1.4.4 node 26.13
    finish — compressor finished, response ends normally no throw no throw no throw
    cut-clean — compressor not finished, body ends cleanly ZlibError ZlibError no throw
    cut-abort — stream unfinished, socket destroyed ECONNRESET ECONNRESET TypeError
    finish-abort — stream finished, then socket destroyed no throw no throw no throw
    identity — no gzip no throw no throw no throw

    Three things fall out of that table:

    1. The trigger is the unfinished gzip stream, not the dropped connection. finish-abort destroys the socket and throws nothing; cut-clean closes the body politely and throws. Any diagnosis that blames a network blip is looking one layer too high.
    2. Node ends the same truncated body cleanly. That is why this only shows up on the Bun host, and why the existing test in sdk/src/impl/__tests__/compressed-stream-cut.test.ts has to tolerate the no-throw case.
    3. Both Bun versions do it. 1.3.14 raises an Error and 1.4.4 a TypeError, but code stays ZlibError in both — so the classifier in common/src/util/error.ts still matches it. Anything matching on error name or instanceof Error would not survive that change.

    Why this build asks for a gzipped stream at all

    Worth putting next to the repro, because it explains why a cut connection turns into a decompression error for some users and not others:

    Where What it says
    common/src/constants/sse-compression.ts The server gzips the stream only for requests carrying x-freebuff-sse-gzip-recovery: 1. Builds that don't send the header get an uncompressed stream, which a cut ends cleanly — so older clients cannot hit this at all.
    sdk/src/impl/model-provider.ts (~635) The SDK sends that header on every chat-completions request.
    common/src/util/error.ts (~440) ZlibError and BrotliDecompressionError are listed in TRANSIENT_NETWORK_ERROR_CODES, with a comment describing this exact case and recording that on 2026-10-08 it produced 545 failed turns in 15 minutes across deploys.

    So the failure mode is known, was mitigated by classifying the error as transient, and still reaches users. The open question is what lets it past the mitigation on a given build.

    That open question makes me suspect the recovery budget rather than zlib: packages/agent-runtime/src/tools/stream-parser.ts sets MAX_CONSECUTIVE_STREAM_RECOVERIES = 3, and the turn fails loudly once three back-to-back recoveries have happened with only partial output between them. If that is what is happening, the fix is about the budget and the message, not the decompressor. Question 2 above is the one that separates those.

    The repro (save as repro-zliberror-sse.mjs; run with bun, or node for contrast)
    #!/usr/bin/env bun
    import http from 'node:http'
    import { constants as zlibConstants, createGzip } from 'node:zlib'
    
    const EVENTS = 3
    
    function startServer(mode) {
      return new Promise((resolve) => {
        const server = http.createServer((_req, res) => {
          const gzipped = mode !== 'identity'
          res.writeHead(200, {
            'Content-Type': 'text/event-stream',
            ...(gzipped ? { 'Content-Encoding': 'gzip' } : {}),
          })
    
          const gzip = gzipped ? createGzip({ flush: zlibConstants.Z_SYNC_FLUSH }) : null
          if (gzip) gzip.pipe(res)
    
          const write = (frame) => (gzip ? gzip.write(frame) : res.write(frame))
          const flush = (cb) => (gzip ? gzip.flush(cb) : cb())
    
          let sent = 0
          const tick = () => {
            write(`data: {"choices":[{"delta":{"content":"chunk-${++sent}"}}]}\n\n`)
            flush(() => {
              if (sent < EVENTS) return setTimeout(tick, 10)
    
              setTimeout(() => {
                if (mode === 'finish' || mode === 'finish-abort') {
                  if (gzip) gzip.end()
                  setTimeout(() => {
                    if (mode === 'finish-abort') res.destroy()
                    else res.end()
                  }, 30)
                  return
                }
                if (gzip) gzip.unpipe(res)
                if (mode === 'cut-abort') res.destroy()
                else res.end()
              }, 20)
            })
          }
          tick()
        })
        server.listen(0, '127.0.0.1', () => resolve(server))
      })
    }
    
    async function run(mode) {
      const server = await startServer(mode)
      const { port } = server.address()
      let events = 0
      try {
        const response = await fetch(`http://127.0.0.1:${port}/`)
        const reader = response.body.getReader()
        const decoder = new TextDecoder()
        for (;;) {
          const { done, value } = await reader.read()
          if (done) break
          events += (decoder.decode(value, { stream: true }).match(/chunk-/g) || []).length
        }
        console.log(`${mode.padEnd(13)} no throw    events=${events}`)
      } catch (error) {
        console.log(
          `${mode.padEnd(13)} THREW       events=${events} type=${error.name} code=${String(error.code)}`,
        )
      } finally {
        server.close()
      }
    }
    
    for (const mode of ['finish', 'cut-clean', 'cut-abort', 'finish-abort', 'identity']) {
      await run(mode)
    }
  5. added
    needs-info
    and removed
    needs-info
    on Nov 17, 2026
  6. aj-nelson-0001 commented on Nov 24, 2026

    @aj-nelson-0001

    Reporter datapoint from the terminal CLI on Linux, since the thread is still waiting on version/OS/behaviour details.

    • Client: freebuff CLI 0.2.36, installed via npm global, run in bash
    • OS: Linux
    • Model: DeepSeek V4.1 Flash
    • Symptom: compression error: ZlibError appears directly above the prompt input, after a turn has completed and its response is fully rendered. No retry, no killed turn, no visible partial output.
    • Session shape: long-running session with a large transcript, which matches the "more frequent after a long session" note.
    • Logs: none available locally — the project-local .freebuff/ directory contains only project-id, so there is nothing to attach. If the CLI has a documented log path, I can collect one.

    This matches the triage finding that the trigger is a cut-clean end to a gzipped SSE body, not a dropped socket: the error surfaces after the events were already decoded and rendered.

    Two questions that would decide how to live with it:

    1. Is there a supported way to opt out of x-freebuff-sse-gzip-recovery: 1 (env var or flag), so the stream is served uncompressed and a truncated body ends cleanly?
    2. Is the banner intended behaviour when the turn has already succeeded, or is it meant to be suppressed unless the recovery budget in stream-parser.ts is actually exhausted?

    If a specific Bun/Node matrix on Linux would help confirm the table from the earlier comment, tell me which commands you want run and I will report the output.

  7. removed
    needs-info
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibot:triagedtype:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions