Skip to content

v8.0.0 — zlib.DeflateRaw only extensible via class keyword #13358

Description

@iarna
  • Version: v8.0.0
  • Platform: Darwin
  • Subsystem: zlib

Extending zlib.DeflateRaw via non-class-keyword doesn't work. You can see this in action with this example:

'use strict'
const zlib = require('zlib');
const inherits = require('util').inherits;

function NotInitialized (options) {
  zlib.DeflateRaw.call(this, options);
  this.prop = true
}
inherits(NotInitialized, zlib.DeflateRaw);
console.log(new NotInitialized())

The above prints out NotInitialized { prop: true }

What I expected it to do, was what this example does:

'use strict'
const zlib = require('zlib');
class Initialized extends zlib.DeflateRaw {
  constructor (options) {
    super(options)
    this.prop = true
  }
}
console.log(new Initialized())

Not doing this initialization means that many stream operations result in crashes. (For example, pipe.)

This shows up in the real world with crc32-stream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    zlibIssues and PRs related to the zlib module and its compression dependencies.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions