Suddenly, I started getting this error on my application when the node engine was upgraded to 10.7.0
TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
Code which was working with node 4.5: fs.writeFile(target, content);
After a bit of debugging I found this in node_internal/fs.js:
function writeFile(path, data, options, callback) {
callback = maybeCallback(callback || options);
...
}
function maybeCallback(cb) {
if (typeof cb === 'function')
return cb;
throw new ERR_INVALID_CALLBACK();
}
Certainly, if do not pass a third/fourth argument here, my code will fail. I want to know is there any way to mitigate this problem. Or if not, what could be the motivation behind such a breaking change. After all, fs.writeFile() is such a basic operation, issues such as these are really a pain while upgrading.