summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/node_file.cc4
-rw-r--r--test/parallel/test-fs-access.js12
-rw-r--r--test/parallel/test-fs-close.js12
3 files changed, 24 insertions, 4 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index 713dcbf633..5ab1a8d3c6 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -421,7 +421,9 @@ void FSReqWrap::Resolve(Local<Value> 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<Value>& args) {
diff --git a/test/parallel/test-fs-access.js b/test/parallel/test-fs-access.js
index 01dbe90eda..d053b9323b 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 0000000000..da0d0dfdc8
--- /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]);
+}));