Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3edb04d

Browse filesBrowse files
dankangMylesBorins
authored andcommitted
src: remove 2nd undefined argument in node_file.cc
In the document for fs, there are several functions that state "No arguments other than a possible exception are given to the completion callback." (ex> fs.access, fs.chmod, fs.close, ..) But, the functions are invoking the callback with two parameters (err, undefined) It causes problems in using several API like [async.waterfall](https://caolan.github.io/async/docs.html#waterfall). PR-URL: #20629 Fixes: #20335 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 83119db commit 3edb04d
Copy full SHA for 3edb04d

File tree

Expand file treeCollapse file tree

3 files changed

+24
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+24
-4
lines changed
Open diff view settings
Collapse file

‎src/node_file.cc‎

Copy file name to clipboardExpand all lines: src/node_file.cc
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,9 @@ void FSReqWrap::Resolve(Local<Value> value) {
421421
Null(env()->isolate()),
422422
value
423423
};
424-
MakeCallback(env()->oncomplete_string(), arraysize(argv), argv);
424+
MakeCallback(env()->oncomplete_string(),
425+
value->IsUndefined() ? 1 : arraysize(argv),
426+
argv);
425427
}
426428

427429
void FSReqWrap::SetReturnValue(const FunctionCallbackInfo<Value>& args) {
Collapse file

‎test/parallel/test-fs-access.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-access.js
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,21 @@ assert.strictEqual(typeof fs.X_OK, 'number');
6464

6565
const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
6666

67-
fs.access(__filename, common.mustCall(assert.ifError));
67+
fs.access(__filename, common.mustCall(function(...args) {
68+
assert.deepStrictEqual(args, [null]);
69+
}));
6870
fs.promises.access(__filename)
6971
.then(common.mustCall())
7072
.catch(throwNextTick);
71-
fs.access(__filename, fs.R_OK, common.mustCall(assert.ifError));
73+
fs.access(__filename, fs.R_OK, common.mustCall(function(...args) {
74+
assert.deepStrictEqual(args, [null]);
75+
}));
7276
fs.promises.access(__filename, fs.R_OK)
7377
.then(common.mustCall())
7478
.catch(throwNextTick);
75-
fs.access(readOnlyFile, fs.F_OK | fs.R_OK, common.mustCall(assert.ifError));
79+
fs.access(readOnlyFile, fs.F_OK | fs.R_OK, common.mustCall(function(...args) {
80+
assert.deepStrictEqual(args, [null]);
81+
}));
7682
fs.promises.access(readOnlyFile, fs.F_OK | fs.R_OK)
7783
.then(common.mustCall())
7884
.catch(throwNextTick);
Collapse file

‎test/parallel/test-fs-close.js‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
const assert = require('assert');
6+
const fs = require('fs');
7+
8+
const fd = fs.openSync(__filename, 'r');
9+
10+
fs.close(fd, common.mustCall(function(...args) {
11+
assert.deepStrictEqual(args, [null]);
12+
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.