Skip to content

Commit

Permalink
avoid ERR_INVALID_ARG_TYPE error on Node.js >= 9 (#23)
Browse files Browse the repository at this point in the history
From nodejs/node@e5c290b 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().
  • Loading branch information
shinnn authored and mafintosh committed Nov 16, 2017
1 parent 90ed7ae commit a430c27
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a430c27

Please sign in to comment.