diff --git a/lib/shared/config-manager/src/CDNConfigSource.ts b/lib/shared/config-manager/src/CDNConfigSource.ts index 32050751e..8a95ee74f 100644 --- a/lib/shared/config-manager/src/CDNConfigSource.ts +++ b/lib/shared/config-manager/src/CDNConfigSource.ts @@ -46,8 +46,6 @@ export class CDNConfigSource extends ConfigSource { resStatus: res.status ?? undefined, } - const projectConfig = (await res.json()) as unknown - this.logger.debug( `Downloaded config, status: ${ res?.status @@ -59,7 +57,9 @@ export class CDNConfigSource extends ConfigSource { `Config not modified, using cache, etag: ${this.configEtag}` + `, last-modified: ${this.configLastModified}`, ) - } else if (res.status === 200 && projectConfig) { + } else if (res.status === 200) { + const projectConfig = (await res.json()) as unknown + const lastModifiedHeader = res.headers.get('last-modified') if (this.isLastModifiedHeaderOld(lastModifiedHeader ?? null)) { this.logger.debug( diff --git a/lib/shared/config-manager/src/index.ts b/lib/shared/config-manager/src/index.ts index c2b631bfb..31ed8004b 100644 --- a/lib/shared/config-manager/src/index.ts +++ b/lib/shared/config-manager/src/index.ts @@ -213,7 +213,6 @@ export class EnvironmentConfigManager { ) let projectConfig: ConfigBody | null = null let retrievalMetadata: Record - let userError: UserError | null = null const startTime = Date.now() let responseTimeMS = 0 @@ -269,7 +268,11 @@ export class EnvironmentConfigManager { } logError(ex) if (ex instanceof UserError) { - userError = ex + throw ex + } else if (this._hasConfig) { + this.logger.warn( + `Failed to download config, using cached version. url: ${url}.`, + ) } } @@ -288,14 +291,7 @@ export class EnvironmentConfigManager { } } - if (this._hasConfig) { - this.logger.warn( - `Failed to download config, using cached version. url: ${url}.`, - ) - } else if (userError) { - this.cleanup() - throw userError - } else { + if (!this._hasConfig) { throw new Error('Failed to download DevCycle config.') } }