diff --git a/lib/fs.js b/lib/fs.js index bd9fde680df..a22da415920 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -87,10 +87,14 @@ function maybeCallback(cb) { // for callbacks that are passed to the binding layer, callbacks that are // invoked from JS already run in the proper scope. function makeCallback(cb) { - if (!util.isFunction(cb)) { + if (util.isNullOrUndefined(cb)) { return rethrow(); } + if (!util.isFunction(cb)) { + throw new TypeError('callback must be a function'); + } + return function() { return cb.apply(null, arguments); };