Skip to content

zlib error with brotli #314

@JiPaix

Description

@JiPaix

I use node v12.16.1 and the code below throws me an error: unexpected end of file at BrotliDecoder.zlibOnError [as onerror] (zlib.js:180:17)

var needle = require("needle")

needle("get", 'https://www.cloudflare.com/', {compressed: true}).then((r) => {
    console.log(r.headers)
}).catch((e) => {
    throw e
})

It works if i comment out this line:

flush: zlib.Z_SYNC_FLUSH,

from:

needle/lib/needle.js

Lines 60 to 64 in 0ef49f6

// Enable Z_SYNC_FLUSH to avoid Z_BUF_ERROR errors (Node PR #2595)
var zlib_options = {
flush: zlib.Z_SYNC_FLUSH,
finishFlush: zlib.Z_SYNC_FLUSH
}

I couldn't reproduce issues from #202 but the code from above still works on all version mentioned

v5.12.0 (which is the latest v5), v6.9.5 (latest v6), and v7.5.0 (latest v7)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions