Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/node_file.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -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);
}

voidFSReqWrap::SetReturnValue(const FunctionCallbackInfo<Value>& args) {
Expand Down
12 changes: 9 additions & 3 deletions test/parallel/test-fs-access.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -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);
Expand Down
12 changes: 12 additions & 0 deletions test/parallel/test-fs-close.js
Original file line numberDiff line numberDiff line change
@@ -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]);
}));