diff --git a/lib/file.js b/lib/file.js index 84a09a8b45..fdb7e25fef 100644 --- a/lib/file.js +++ b/lib/file.js @@ -29,10 +29,12 @@ exports.write = function (filename, data, encoding) { posix.write(fd, _data, 0, encoding) .addErrback(function () { posix.close(fd); + promise.emitError(); }) .addCallback(function (written) { if (written === _data.length) { posix.close(fd); + promise.emitSuccess(); } else { doWrite(_data.slice(written)); }