1'use strict'; 2 3const common = require('../common'); 4 5const assert = require('assert'); 6const zlib = require('zlib'); 7 8// Verify that the zlib transform does clean up 9// the handle when calling destroy. 10 11{ 12 const ts = zlib.createGzip(); 13 ts.destroy(); 14 assert.strictEqual(ts._handle, null); 15 16 ts.on('close', common.mustCall(() => { 17 ts.close(common.mustCall()); 18 })); 19} 20 21{ 22 // Ensure 'error' is only emitted once. 23 const decompress = zlib.createGunzip(15); 24 25 decompress.on('error', common.mustCall((err) => { 26 decompress.close(); 27 })); 28 29 decompress.write('something invalid'); 30 decompress.destroy(new Error('asd')); 31} 32