I believe there is a bug in:
https://github.com/pkgcloud/pkgcloud/blob/master/lib/pkgcloud/openstack/storage/client/files.js#L124
The following code is being called:
writableStream = this._request(uploadOptions);
which in turn calls:
https://github.com/pkgcloud/pkgcloud/blob/master/lib/pkgcloud/openstack/client.js#L192
Client.prototype._request = function (options, callback) {
var self = this;
if (!self._isAuthorized()) {
self.emit('log::trace', 'Not-Authenticated, inlining Auth...');
var proxyStream = through();
proxyStream.pause();
self.auth(function (err) {
if (err) {
self.emit('log::error', 'Error with inline authentication', err);
return errs.handle(err, callback); // <--- PROBLEM
}
//...
This creates a problem, since writableStream = this._request(uploadOptions); does not pass a callback.
The code for errs.handle is bellow:
exports.handle = function (error, callback, stream) {
error = exports.create(error);
if (typeof callback === 'function') {
callback(error);
}
if (typeof callback !== 'function' || stream) {
var emitter = stream || callback || new events.EventEmitter();
process.nextTick(function () { emitter.emit('error', error); });
return emitter;
}
};
As you can see, errs.handle expects a callback or a stream. If neither is provided it creates a new events.EventEmitter() and emits error on it on a next tick.
Since that new event emitter does not have any error listeners Node 4 throws an error, that cannot be caught by implementations using your library.
A proposed solution is to modify openstack/storage/client/files.js as follows:
writableStream = this._request(uploadOptions, function(err){
if(err){
proxyStream.emit('error', err);
}
});
That what users of client.upload can subscribe to the error and handle it properly.
I believe there is a bug in:
https://github.com/pkgcloud/pkgcloud/blob/master/lib/pkgcloud/openstack/storage/client/files.js#L124
The following code is being called:
which in turn calls:
https://github.com/pkgcloud/pkgcloud/blob/master/lib/pkgcloud/openstack/client.js#L192
This creates a problem, since
writableStream = this._request(uploadOptions);does not pass a callback.The code for
errs.handleis bellow:As you can see, errs.handle expects a callback or a stream. If neither is provided it creates a
new events.EventEmitter()and emits error on it on a next tick.Since that new event emitter does not have any error listeners Node 4 throws an error, that cannot be caught by implementations using your library.
A proposed solution is to modify openstack/storage/client/files.js as follows:
That what users of
client.uploadcan subscribe to the error and handle it properly.