Skip to content

Commit 2249234

Browse files
committed
fs: invoke callbacks with undefined context
Many callbacks appear to be invoked with `this` set to `undefined` including `fs.stat()`, `fs.lstat()`, and `fs.fstat()`. However, some such as `fs.open()` and `fs.mkdtemp()` invoke their callbacks with `this` set to `null`. Change to `undefined`. PR-URL: #14645 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent c6126b1 commit 2249234

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lib/fs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function makeCallback(cb) {
132132
}
133133

134134
return function() {
135-
return cb.apply(null, arguments);
135+
return cb.apply(undefined, arguments);
136136
};
137137
}
138138

test/parallel/test-fs-mkdtemp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ assert(common.fileExists(utf8));
2020
function handler(err, folder) {
2121
assert.ifError(err);
2222
assert(common.fileExists(folder));
23-
assert.strictEqual(this, null);
23+
assert.strictEqual(this, undefined);
2424
}
2525

2626
fs.mkdtemp(path.join(common.tmpDir, 'bar.'), common.mustCall(handler));

test/parallel/test-fs-stat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fs.open('.', 'r', undefined, common.mustCall(function(err, fd) {
6666
// Confirm that we are not running in the context of the internal binding
6767
// layer.
6868
// Ref: https://github.com/nodejs/node/commit/463d6bac8b349acc462d345a6e298a76f7d06fb1
69-
assert.strictEqual(this, null);
69+
assert.strictEqual(this, undefined);
7070
}));
7171

7272
// fstatSync

0 commit comments

Comments
 (0)