Welcome to the Linux Foundation Forum!

Working with Streams - Readable-Writable Streams bug with zlib.createGunzip on node 14.15.2+

Options

The Gzip example in Working with Streams - Readable-Writable Streams fails when running on node 14.15.2+. There appears to be a fix but it is not backported to Node 14 LTS yet (https://github.com/nodejs/node/issues/36615). In the same issue it appears that if you add const stream = require('stream'); that will provide a temporary fix. The working code is as per below

'use strict'
const stream = require('stream');
const { createGzip } = require('zlib')
const transform = createGzip()
transform.on('data', (data) => {
  console.log('got gzip data', data.toString('base64'))
})
transform.write('first')
setTimeout(() => {
  transform.end('second')
}, 500)

Comments

  • davidmarkclements
    Options

    very nice work @seetdev - I don't see a bug of this severity taking long to back port so I'm going to leave the material as is for now and check back in at a later date

Categories

Upcoming Training