diff --git a/src/node_file.cc b/src/node_file.cc index 713dcbf6331898..5ab1a8d3c641eb 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -421,7 +421,9 @@ void FSReqWrap::Resolve(Local value) { Null(env()->isolate()), value }; - MakeCallback(env()->oncomplete_string(), arraysize(argv), argv); + MakeCallback(env()->oncomplete_string(), + value->IsUndefined() ? 1 : arraysize(argv), + argv); } void FSReqWrap::SetReturnValue(const FunctionCallbackInfo& args) { diff --git a/test/parallel/test-fs-access.js b/test/parallel/test-fs-access.js index 01dbe90eda8435..d053b9323bc275 100644 --- a/test/parallel/test-fs-access.js +++ b/test/parallel/test-fs-access.js @@ -64,15 +64,21 @@ assert.strictEqual(typeof fs.X_OK, 'number'); const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; -fs.access(__filename, common.mustCall(assert.ifError)); +fs.access(__filename, common.mustCall(function(...args) { + assert.deepStrictEqual(args, [null]); +})); fs.promises.access(__filename) .then(common.mustCall()) .catch(throwNextTick); -fs.access(__filename, fs.R_OK, common.mustCall(assert.ifError)); +fs.access(__filename, fs.R_OK, common.mustCall(function(...args) { + assert.deepStrictEqual(args, [null]); +})); fs.promises.access(__filename, fs.R_OK) .then(common.mustCall()) .catch(throwNextTick); -fs.access(readOnlyFile, fs.F_OK | fs.R_OK, common.mustCall(assert.ifError)); +fs.access(readOnlyFile, fs.F_OK | fs.R_OK, common.mustCall(function(...args) { + assert.deepStrictEqual(args, [null]); +})); fs.promises.access(readOnlyFile, fs.F_OK | fs.R_OK) .then(common.mustCall()) .catch(throwNextTick); diff --git a/test/parallel/test-fs-close.js b/test/parallel/test-fs-close.js new file mode 100644 index 00000000000000..da0d0dfdc832d8 --- /dev/null +++ b/test/parallel/test-fs-close.js @@ -0,0 +1,12 @@ +'use strict'; + +const common = require('../common'); + +const assert = require('assert'); +const fs = require('fs'); + +const fd = fs.openSync(__filename, 'r'); + +fs.close(fd, common.mustCall(function(...args) { + assert.deepStrictEqual(args, [null]); +}));