Skip to content

Commit 977c70f

Browse files
authored
fix: Single-part uploads not retried when request fails (#122)
* fix: Single-part uploads not retried when request fails * Do not call abort for single-part uploads
1 parent 20f4600 commit 977c70f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

source/uploader.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ export class Uploader {
229229
});
230230
logger.debug("Upload complete", this.componentId);
231231
} catch (error) {
232+
try {
233+
await this.cleanup();
234+
} catch (cleanupError) {
235+
logger.error("Clean up failed", cleanupError);
236+
}
232237
if (this.onError) {
233238
this.onError(error as Error);
234239
}
@@ -464,16 +469,15 @@ export class Uploader {
464469
);
465470
this.xhr.open("PUT", url, true);
466471
this.xhr.onabort = async () => {
472+
this.aborted = true;
467473
if (this.onAborted) {
468474
this.onAborted();
469475
}
470-
await this.cleanup();
471476
reject(
472477
new CreateComponentError("Upload aborted by client", "UPLOAD_ABORTED")
473478
);
474479
};
475480
this.xhr.onerror = async () => {
476-
await this.cleanup();
477481
reject(
478482
new CreateComponentError(`Failed to upload file: ${this.xhr!.status}`)
479483
);

0 commit comments

Comments
 (0)