diff --git a/source/session.ts b/source/session.ts index ca06f57..b2e98b7 100644 --- a/source/session.ts +++ b/source/session.ts @@ -1090,7 +1090,7 @@ export class Session< }, }); - uploader.start(); + uploader.start().catch(reject); }); } } diff --git a/source/uploader.ts b/source/uploader.ts index 2e16c42..cea1f81 100644 --- a/source/uploader.ts +++ b/source/uploader.ts @@ -177,7 +177,14 @@ export class Uploader> { /** Initiate upload. Promise is resolved once preflight is complete and upload started. */ async start() { logger.debug("Upload starting", this.componentId); - await this.uploadPreflight(); + try { + await this.uploadPreflight(); + } catch (error) { + if (this.onError) { + this.onError(error as Error); + } + throw error; + } if (!this.uploadMetadata) { throw new Error("Failed to get upload metadata"); }