NodeJS v8 "err": {"message": "fsReadFileAsync(...).then(...).then(...).catch(...).done is not a function",
After upgrading code and libraries, you might run into
"err":{"message":"fsReadFileAsync(...).then(...).then(...).catch(...).done is not a function",
An example erroneous code
const fsReadFileAsync = util.promisify(fs.readFile.bind(fs));
const fsWriteFileAsync = util.promisify(fs.writeFile.bind(fs));
// First apply changes to fstab
fsReadFileAsync(this._fstabFilename, "utf8")
.then(function (contents) {
var modifiedContents =
self._alterFstab(
contents,
networkStorage.active,
networkStorage.host,
networkStorage.remotePath);
return fsWriteFileAsync(self._fstabFilename, modifiedContents);
})
// Save our settings unless there was an error applying fstab changes
.then(function () {
self._saveSettings(networkStorage, callback);
})
.catch(function (error) {
Helpers.Log.Error({
fstabPath: self._fstabFilename,
settings: networkStorage,
error: error.stack
}, "Error applying changes to fstab");
callback(Errors.InternalServer());
}).done();
Solution
Remove .done()
This happens when upgrading from var QFS = require("q-io/fs"); to native util.promisify()
Recent Comments