diff --git a/src/download/download-engine/engine/download-engine-browser.ts b/src/download/download-engine/engine/download-engine-browser.ts index 6086a0f..851d568 100644 --- a/src/download/download-engine/engine/download-engine-browser.ts +++ b/src/download/download-engine/engine/download-engine-browser.ts @@ -44,8 +44,6 @@ export default class DownloadEngineBrowser { let throwErr: Error | null = null; + const tryHeaders = "tryHeaders" in this.options && this.options.tryHeaders ? this.options.tryHeaders.slice() : []; + const fetchDownloadInfoCallback = async (): Promise => { try { return await this.fetchDownloadInfoWithoutRetry(url); } catch (error: any) { if (error instanceof HttpError && !this.retryOnServerError(error)) { - if ("tryHeaders" in this.options && this.options.tryHeaders?.length) { - this.options.headers = this.options.tryHeaders.shift(); + if ("tryHeaders" in this.options && tryHeaders.length) { + this.options.headers = tryHeaders.shift(); await sleep(this.options.tryHeadersDelay ?? 0); return await fetchDownloadInfoCallback(); }