summaryrefslogtreecommitdiff
path: root/test/parallel/test-zlib-destroy-pipe.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-zlib-destroy-pipe.js')
-rw-r--r--test/parallel/test-zlib-destroy-pipe.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/parallel/test-zlib-destroy-pipe.js b/test/parallel/test-zlib-destroy-pipe.js
new file mode 100644
index 0000000000..38b8a5b492
--- /dev/null
+++ b/test/parallel/test-zlib-destroy-pipe.js
@@ -0,0 +1,21 @@
+'use strict';
+
+const common = require('../common');
+const zlib = require('zlib');
+const { Writable } = require('stream');
+
+// verify that the zlib transform does not error in case
+// it is destroyed with data still in flight
+
+const ts = zlib.createGzip();
+
+const ws = new Writable({
+ write: common.mustCall((chunk, enc, cb) => {
+ setImmediate(cb);
+ ts.destroy();
+ })
+});
+
+const buf = Buffer.allocUnsafe(1024 * 1024 * 20);
+ts.end(buf);
+ts.pipe(ws);