Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

511
Views
zlib decompression of the same data not working (Z_BUF_ERROR)

I have this code in Python:

import zlib

raw = bytes.fromhex("789C34C9410AC2301005D0BBFC752289A88BB94A53CAD8061B48D3329D2A1A7277DDB87BF02A14548E9C0DF63FD60DE49DC104AA98238BDE23EB908A467972065DFCF9FAFB4185C708EAD0053C58E38BDF7693C92E9C8A9DFDE716606AC0924659F7007227D77AF4AD7D010000FFFF")

buffer = bytearray()
inflator = zlib.decompressobj()
buffer.extend(raw)
msg = inflator.decompress(buffer)
    
print("[buffer] ", msg)

Result:

[buffer] b'{"t":null,"s":null,"op":10,"d":{"heartbeat_interval":41250,"_trace":["[\"gateway-prd-main-h1z6\",{\"micros\":0.0}]"]}}'

That data could be successfully decompressed in Python.
Then I have similar code in javascript (typescript):

import zlib from "zlib"

const raw = "789C34C9410AC2301005D0BBFC752289A88BB94A53CAD8061B48D3329D2A1A7277DDB87BF02A14548E9C0DF63FD60DE49DC104AA98238BDE23EB908A467972065DFCF9FAFB4185C708EAD0053C58E38BDF7693C92E9C8A9DFDE716606AC0924659F7007227D77AF4AD7D010000FFFF";

let msg;
let buffer;

buffer = Buffer.from(raw, "hex");
msg = zlib.inflateSync(buffer);
console.log("[buffer] " + msg.toString("utf-8"));

Result:

Error: unexpected end of file
at Zlib.zlibOnError [as onerror] (node:zlib:190:17)
at processChunkSync (node:zlib:456:12)
at zlibBufferSync (node:zlib:178:12)
at Object.syncBufferWrapper [as inflateSync] (node:zlib:791:14)
at Object.
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module.m._compile (C:\Users\hanziKR Developer\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:1455:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions. [as .ts]
at Module.load (node:internal/modules/cjs/loader:981:32) {
errno: -5,
code: 'Z_BUF_ERROR'
}

There it has an error. Why is there an error in one, but not the other?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Because your Python code is ignoring the error. In both cases your zlib stream ends prematurely.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!