From 424ba01ea99b39ef2306e3887ea63b815abfc4c1 Mon Sep 17 00:00:00 2001 From: Shinnosuke Watanabe Date: Thu, 16 Nov 2017 10:11:01 +0900 Subject: [PATCH] avoid `ERR_INVALID_ARG_TYPE` error on Node.js >= 9 From https://github.com/nodejs/node/commit/e5c290bed9775bdddd74650995f3358373af8097 included in Node.js >= 9, fs.WriteStream#close() requires a callback function and throws an error when no arguments are provided. This patch makes pump compatible with Node.js >= 9 by passing a noop function to fs.WriteStream#close(). --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 060ce5f..f0c639a 100644 --- a/index.js +++ b/index.js @@ -37,7 +37,7 @@ var destroyer = function (stream, reading, writing, callback) { if (destroyed) return destroyed = true - if (isFS(stream)) return stream.close() // use close for fs streams to avoid fd leaks + if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want if (isFn(stream.destroy)) return stream.destroy()