Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions source/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ export class Uploader {
});
logger.debug("Upload complete", this.componentId);
} catch (error) {
try {
await this.cleanup();
} catch (cleanupError) {
logger.error("Clean up failed", cleanupError);
}
if (this.onError) {
this.onError(error as Error);
}
Expand Down Expand Up @@ -464,16 +469,15 @@ export class Uploader {
);
this.xhr.open("PUT", url, true);
this.xhr.onabort = async () => {
this.aborted = true;
if (this.onAborted) {
this.onAborted();
}
await this.cleanup();
reject(
new CreateComponentError("Upload aborted by client", "UPLOAD_ABORTED")
);
};
this.xhr.onerror = async () => {
await this.cleanup();
reject(
new CreateComponentError(`Failed to upload file: ${this.xhr!.status}`)
);
Expand Down