-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
duplicateIssues and PRs that are duplicates of other issues or PRs.Issues and PRs that are duplicates of other issues or PRs.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.
Description
- Version: 10.1.0
- Platform: Darwin 17.5.0 Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT 2018; root:xnu-4570.51.2~1/RELEASE_X86_64 x86_64
- Subsystem: fs
In node 10, fs callbacks are returning an extra undefined value. This violates the current api.
The following code
const fs = require('fs');
function callback() {
console.log(arguments);
}
fs.unlink('/tmp/existing-file.txt', callback)will output: [Arguments] { '0': null, '1': undefined }
The expected output should be [Arguments] { '0': null }, which it is in node 8.
This creates problems for libraries such as async that expect the signature of fs to only return the error in the callback. fs.unlink is listed above but I have seen the behavior in other methods, such as fs.link.
Sample async code this causes issues with:
const waterfall = require('async/waterfall')
waterfall([
(callback) => fs.unlink('/tmp/existing-file.txt', callback),
(callback) => {
...
// Callback is undefined here because "undefined" is being passed into the `unlink` callback along with a null error
callback()
}
])In order to mitigate the issue the above code would have to change
(callback) => fs.unlink('/tmp/existing-file.txt', callback),to
(callback) => fs.unlink('/tmp/existing-file.txt', err => callback(err)),Metadata
Metadata
Assignees
Labels
duplicateIssues and PRs that are duplicates of other issues or PRs.Issues and PRs that are duplicates of other issues or PRs.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.