Skip to content

Node v15.6.0 changes the behavior of .end on zlib.DeflateRaw #37027

@Aaron1011

Description

@Aaron1011
  • Version: v15.6.0
  • Platform: Linux ArchLaptop 5.10.9-arch1-1 deps: update openssl to 1.0.1j #1 SMP PREEMPT Tue, 19 Jan 2021 22:06:06 +0000 x86_64 GNU/Linux
  • Subsystem: zlib

What steps will reproduce the bug?

The following code:

const {DeflateRaw} = require('zlib');

class MyStream extends DeflateRaw {
    constructor(options) {
        super(options);
    }

    write(chunk, enc, cb) {
        console.log("Write: " + chunk + " " + enc + " " + cb);
    }
}

console.log("Running");
const s = new MyStream();
s.end(Buffer.from('hello world'));

produces the following output on Node v15.6.0:

Running

On Node v15.5.0 and below, it produces the output:

Running
Write: hello world undefined undefined

How often does it reproduce? Is there a required condition?

This reproduces 100% of the time

What is the expected behavior?

Calling end should call the overridden write method with the supplied data, as in Node v15.5.0 and below.

What do you see instead?

The overridden write method is not called.

Additional information

This leads to node-archiver producing invalid ZIP files: archiverjs/node-archiver#491

PR #36618 seems like it might be related

Metadata

Metadata

Assignees

No one assigned

    Labels

    streamIssues and PRs related to the stream subsystem.zlibIssues and PRs related to the zlib subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions