forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Ensure automatic destruction only happens after both 'end' and 'finish' has been emitted through autoDestroy. - Ensure close() callback is always invoked. - Ensure 'error' is only emitted once. PR-URL: nodejs#32220 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
Showing
2 changed files
with
34 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const common = require('../common'); | ||
|
||
const assert = require('assert'); | ||
const zlib = require('zlib'); | ||
|
||
// Verify that the zlib transform does clean up | ||
// the handle when calling destroy. | ||
|
||
const ts = zlib.createGzip(); | ||
ts.destroy(); | ||
assert.strictEqual(ts._handle, null); | ||
{ | ||
const ts = zlib.createGzip(); | ||
ts.destroy(); | ||
assert.strictEqual(ts._handle, null); | ||
|
||
ts.on('close', common.mustCall(() => { | ||
ts.close(common.mustCall()); | ||
})); | ||
} | ||
|
||
{ | ||
// Ensure 'error' is only emitted once. | ||
const decompress = zlib.createGunzip(15); | ||
|
||
decompress.on('error', common.mustCall((err) => { | ||
decompress.close(); | ||
})); | ||
|
||
decompress.write('something invalid'); | ||
decompress.destroy(new Error('asd')); | ||
} |