Node gunzipSync on truncated data: "unexpected end of file" (Z_BUF_ERROR); with finishFlush Z_SYNC_FLUSH you get a runtime-dependent partial result
A truncated gzip (or empty input) makes gunzipSync, inflateSync and brotliDecompressSync throw Error: unexpected end of file with code Z_BUF_ERROR. The documented workaround, gunzipSync(buf, { finishFlush: zlib.constants.Z_SYNC_FLUSH }), returns whatever could be decoded without any error or indication of truncation, and the amount differs by runtime: for a 12,000-byte input with the last 20 compressed bytes removed, Node 26.7 returned 6,721 bytes and Bun 1.3.14 returned 10,075. Code that uses Z_SYNC_FLUSH to read partial logs can thus mistake truncated data for complete data. Fix: use finishFlush only for best-effort recovery, and verify completeness separately (store the original length or a checksum, or check that the gzip trailer was reached). Node v26.7.0 (Bun 1.3.14 for comparison), macOS.