-
-
Notifications
You must be signed in to change notification settings - Fork 237
[1.0.0] Add better error trace on transform streams #227
Comments
I've created something for this that could be included in the package. Just want your feedback before I refactor it into the cfs-storage-adapter. How can the transformWrite function notify that an error has occured?
What will the error handler do?
Open
My current transformErrorHandler code/**
* Wrapper that handles errors that are thrown while transforming.
* It saves the error in the copy and emits stored.
* @param {string} storageName The name of the storage.
* @param {Function} transformFunction The transformation function.
* @returns {Function}
*/
var handleTransformErrors = function (storageName, transformFunction) {
return function (file, readStream, writeStream) {
var handleError = function (error) {
if (_.isObject(error) && error.errorType === 'Meteor.Error') {
error = _.pick(error, 'error', 'reason', 'details');
}
console.log('handleTransformError', error);
file.copies[storageName].error = error;
writeStream.emit('error', error);
readStream.unpipe(writeStream);
writeStream.emit('stored', {
fileKey: '',
size: 0,
storedAt: new Date()
});
};
try {
transformFunction(file, readStream, writeStream, handleError);
} catch (error) {
handleError(error);
}
};
}; Usagevar eventPhotos = new FS.Store.S3('eventPhotos', {
// Options...
transformWrite: handleTransformErrors('eventPhotos', function (file, readStream, writeStream, handleError) {
// Transform code.
// Trigger error with throw:
throw new Meteor.Error(500, 'Transform failed');
// Or trigger error with callback:
handleError(new Meteor.Error(500, 'Transform failed');
})
}); |
@raix may have comments, but I think your ideas generally make sense. If you want to put together a PR, we might have more comments on the actual implementation of it. The important point is to properly catch all errors and emit "error" instead of "stored". You don't have to worry about funneling the error back to the collection because we can do that when we add the collection emitter feature. I agree that adding an |
Error: Error storing file to the Uploads store: socket hang up error and i have not used transformWrite Error: Error storing file to the Uploads store: socket hang up |
im having the same issue only under meteor-up GET http://mydomain.com/sockjs/info?cb=7sbwqvwd9v net::ERR_CONNECTION_REFUSED Error: "Queue" network [undefined], Error
at http://mydomain.com/d4113048f6873f06ed8b5ce655e8b1f5a39feb00.js:22:23751
at http://mydomain.com/d4113048f6873f06ed8b5ce655e8b1f5a39feb00.js:22:21121
at http://mydomain.com/d4113048f6873f06ed8b5ce655e8b1f5a39feb00.js:1:8368
at XMLHttpRequest.v.onreadystatechange (http://mydomain.com/d4113048f6873f06ed8b5ce655e8b1f5a39feb00.js:22:22428) this is my issue issue on mup |
+1, this is really needed... My natural thought would be that I'd accept any error handling really... PS: Has any work been started on this? |
Hey Sanjo, If I wanted to use your Thanks. |
@evolross Just copy the code into your project. I had it in the file where I did all the CollectionFS stuff. The code is licensed under MIT license. |
I got something working using your above Since the error is ultimately set in |
Issues like #225 are a bit hard to debug, there should be a better error message explaining that the Error toke place inside eg.
transformWrite
and hand the error message and trace if available.currently the error event is unhandled in the cfs-storage-adapter transform-stream.js
The text was updated successfully, but these errors were encountered: