This repository was archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
mkfile error throws instead of callback #6
Copy link
Copy link
Open
Description
In localfs.js#L343 there is an issue where the callback is called with an error but no meta object.
In the callback error case meta.stream is accessed. Since meta is undefined, this throws, making the entire point of a callback for the error case meaningless. (and as it so happens, this crashes my c9 install)
var callback = function (err, meta) {
if (called) {
if (err) {
if (meta.stream) meta.stream.emit("error", err);
else console.error(err.stack);
}
else if (meta.stream) meta.stream.emit("saved");
return;
}
called = true;
return realCallback.apply(this, arguments);
};
if (options.stream && !options.stream.readable) {
return callback(new TypeError("options.stream must be readable."));
}Changing that like the following should fix this.
var callback = function (err, meta) {
if (called) {
if (err) {
if (meta && meta.stream) meta.stream.emit("error", err);
else console.error(err.stack);
}
else if (meta && meta.stream) meta.stream.emit("saved");
return;
}
called = true;
return realCallback.apply(this, arguments);
};
if (options.stream && !options.stream.readable) {
return callback(new TypeError("options.stream must be readable."));
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels