-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@uppy/aws-s3 response undefined while listening for "upload-error" event #5683
base: main
Are you sure you want to change the base?
@uppy/aws-s3 response undefined while listening for "upload-error" event #5683
Conversation
Diff output filesdiff --git a/packages/@uppy/aws-s3/lib/index.js b/packages/@uppy/aws-s3/lib/index.js
index b2bf3c6..3643c5b 100644
--- a/packages/@uppy/aws-s3/lib/index.js
+++ b/packages/@uppy/aws-s3/lib/index.js
@@ -623,8 +623,17 @@ function _uploadLocalFile2(file) {
});
};
const onError = err => {
+ var _file$progress;
this.uppy.log(err);
- this.uppy.emit("upload-error", file, err);
+ const errorResponse = {
+ status: (err == null ? void 0 : err.status) || 500,
+ body: {
+ message: err instanceof Error ? err.message : "Unknown error",
+ },
+ bytesUploaded:
+ (file == null || (_file$progress = file.progress) == null ? void 0 : _file$progress.bytesUploaded) || 0,
+ };
+ this.uppy.emit("upload-error", file, err, errorResponse);
this.resetUploaderReferences(file.id);
reject(err);
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it makes sense to magically derive this from the error, it should be passed explicitly where we have access to the response (where onError is called, as the second argument)
However it seems we never emit a response anywhere so basically the types are lying. It would be good to have it consistent everywhere though.

yeah ! just found one instance of 'upload-error' where response was passed uppy/packages/@uppy/xhr-upload/src/index.ts Lines 270 to 277 in f877dac
we're building the error response using so basically it means we can close #5672 as |
I think it would be nice if all uploaders did pass the actual request that failed to upload-error. The problem is that a generalized type doesn't make sense for that. So we would have to remove the response argument from the definition in @uppy/core and then inject the type into the namespace for each uploader, as is done here: uppy/packages/@uppy/transloadit/src/index.ts Lines 183 to 221 in 38333f7
Also in the case of It would require more digging to figure where the failed request is surfaced in each uploader and how to get it to Up to you if you want to go deeper or do something else. |
Hi @Murderlon , this looked like an easy fix for #5672 but there are a few instances in the codebase where we're emitting "upload-error" without passing the response e.g.
uppy/packages/@uppy/transloadit/src/index.ts
Lines 833 to 837 in f877dac
I can see that response is an optional param in the interface , so then it seems like it's by design that response was not passed correct ? aren't we expecting users to see the response in case of upload-error event in these cases ?
not sure about this hence will keep it as a Draft PR for now :)
let me know if this works I'll add tests.