diff --git a/scripts/build/package.ts b/scripts/build/package.ts index 4ffc59484e1..84aacf01c39 100644 --- a/scripts/build/package.ts +++ b/scripts/build/package.ts @@ -24,7 +24,7 @@ import * as fs from 'fs-extra' import { betaUrl } from '../../src/dev/config' const packageJsonFile = './package.json' -const webpackConfigJsFile = './webpack.config.js' +const webpackConfigJsFile = './webpack.base.config.js' function parseArgs() { // Invoking this script with argument "foo": diff --git a/src/auth/providers/credentialsProviderManager.ts b/src/auth/providers/credentialsProviderManager.ts index 44c3da81344..70f71e7a90d 100644 --- a/src/auth/providers/credentialsProviderManager.ts +++ b/src/auth/providers/credentialsProviderManager.ts @@ -32,9 +32,7 @@ export class CredentialsProviderManager { telemetry.aws_loadCredentials.emit({ credentialSourceId: telemType, value: 1 }) providers = providers.concat(provider) } else { - getLogger().verbose( - `provider for ${provider.getCredentialsId().credentialTypeId} unavailable in this environment` - ) + getLogger().verbose('auth: "%s" provider unavailable', provider.getCredentialsId().credentialTypeId) } } diff --git a/src/auth/providers/sharedCredentialsProviderFactory.ts b/src/auth/providers/sharedCredentialsProviderFactory.ts index c79da03cdbc..7a8ea49f62e 100644 --- a/src/auth/providers/sharedCredentialsProviderFactory.ts +++ b/src/auth/providers/sharedCredentialsProviderFactory.ts @@ -47,18 +47,17 @@ export class SharedCredentialsProviderFactory extends BaseCredentialsProviderFac private async loadSharedCredentialsProviders(): Promise { this.resetProviders() - this.logger.verbose('Loading all Shared Credentials Sections') const result = await loadSharedCredentialsSections() if (result.errors.length > 0) { const errors = result.errors.map(e => e.message).join('\t\n') - getLogger().verbose(`credentials: errors occurred while parsing:\n%s`, errors) + getLogger().warn(`credentials: errors while parsing:\n%s`, errors) } this.loadedCredentialsModificationMillis = await this.getLastModifiedMillis(getCredentialsFilename()) this.loadedConfigModificationMillis = await this.getLastModifiedMillis(getConfigFilename()) await updateAwsSdkLoadConfigEnvVar() - getLogger().verbose(`credentials: found sections: ${result.sections.map(s => `${s.type}:${s.name}`)}`) + getLogger().verbose(`credentials: found sections: ${result.sections.map(s => `${s.type}:${s.name}`).join(' ')}`) for (const section of result.sections) { if (section.type === 'profile') { await this.addProviderIfValid( diff --git a/src/auth/sso/cache.ts b/src/auth/sso/cache.ts index 2154761b0fb..b245068817d 100644 --- a/src/auth/sso/cache.ts +++ b/src/auth/sso/cache.ts @@ -46,7 +46,7 @@ export function getRegistrationCache(directory = getCacheDir()): KeyedCache ({ ...data, expiresAt: new Date(data.expiresAt) }) const write = (data: ClientRegistration) => ({ ...data, expiresAt: data.expiresAt.toISOString() }) - const logger = (message: string) => getLogger().debug(`SSO registration cache: ${message}`) + const logger = (message: string) => getLogger().debug('auth: SSO registration cache: %s', message) const cache: KeyedCache = createDiskCache( (registrationKey: RegistrationKey) => getRegistrationCacheFile(directory, registrationKey), logger diff --git a/src/auth/sso/ssoAccessTokenProvider.ts b/src/auth/sso/ssoAccessTokenProvider.ts index 03dc93f671b..b616e4116f7 100644 --- a/src/auth/sso/ssoAccessTokenProvider.ts +++ b/src/auth/sso/ssoAccessTokenProvider.ts @@ -75,9 +75,10 @@ export class SsoAccessTokenProvider { ) {} public async invalidate(): Promise { - await Promise.all([ - this.cache.token.clear(this.tokenCacheKey), - this.cache.registration.clear(this.registrationCacheKey), + // Use allSettled() instead of all() to ensure all clear() calls are resolved. + await Promise.allSettled([ + this.cache.token.clear(this.tokenCacheKey, 'SsoAccessTokenProvider.invalidate()'), + this.cache.registration.clear(this.registrationCacheKey, 'SsoAccessTokenProvider.invalidate()'), ]) } @@ -114,7 +115,7 @@ export class SsoAccessTokenProvider { return await this.authorize(registration) } catch (err) { if (err instanceof SSOOIDCServiceException && isClientFault(err)) { - await this.cache.registration.clear(cacheKey) + await this.cache.registration.clear(cacheKey, `client fault: SSOOIDCServiceException: ${err.message}`) } throw err @@ -141,7 +142,10 @@ export class SsoAccessTokenProvider { } as AwsRefreshCredentials) if (err instanceof SSOOIDCServiceException && isClientFault(err)) { - await this.cache.token.clear(this.tokenCacheKey) + await this.cache.token.clear( + this.tokenCacheKey, + `client fault: SSOOIDCServiceException: ${err.message}` + ) } } diff --git a/src/shared/utilities/cacheUtils.ts b/src/shared/utilities/cacheUtils.ts index 76ed6ffd0fc..07185e1949e 100644 --- a/src/shared/utilities/cacheUtils.ts +++ b/src/shared/utilities/cacheUtils.ts @@ -33,11 +33,12 @@ export interface KeyedCache { save(key: K, data: T): Promise /** - * Removes the data stored at {@link key}, if any. + * Deletes data stored at {@link key}, if any. * * @param key Target key to clear. + * @param reason Partial log message explaining why the data is being deleted. */ - clear(key: K): Promise + clear(key: K, reason: string): Promise } /** @@ -71,7 +72,7 @@ export function mapCache(cache: KeyedCache, get: (data: T) => U, const getIf = (data?: T) => (data !== undefined ? get(data) : undefined) return { - clear: key => cache.clear(key), + clear: (key, reason) => cache.clear(key, reason), load: key => cache.load(key).then(getIf), save: (key, data) => cache.save(key, set(data)), } @@ -91,10 +92,10 @@ export function createDiskCache( mapKey: (key: K) => string, logger?: (message: string) => void ): KeyedCache { - function log(prefix: string, key: K): void { + function log(msg: string, key: K): void { if (logger) { const keyMessage = typeof key === 'object' ? JSON.stringify(key) : key - logger(`${prefix} for key '${keyMessage}'`) + logger(`${msg} key: ${keyMessage}`) } } @@ -104,11 +105,11 @@ export function createDiskCache( try { const result = JSON.parse(await SystemUtilities.readFile(target)) - log('load succeeded', key) + log('loaded', key) return result } catch (error) { if (isFileNotFoundError(error)) { - log('load missed', key) + log('read failed (file not found)', key) return } @@ -131,16 +132,16 @@ export function createDiskCache( }) } - log('save succeeded', key) + log('saved', key) }, - clear: async key => { + clear: async (key, reason) => { const target = mapKey(key) try { await SystemUtilities.delete(target) } catch (error) { if (isFileNotFoundError(error)) { - return log('clear succeeded, file does not exist', key) + return log('file not found', key) } throw ToolkitError.chain(error, `Failed to delete "${target}"`, { @@ -149,7 +150,7 @@ export function createDiskCache( }) } - log('clear succeeded', key) + log(`deleted (reason: ${reason})`, key) }, } } @@ -158,9 +159,9 @@ export function createSecretsCache( secrets: vscode.SecretStorage, logger?: (message: string) => void ): KeyedCache { - function log(prefix: string, key: string): void { + function log(msg: string, key: string): void { if (logger) { - logger(`${prefix} for key '${key}'`) + logger(`${msg} key: ${key}`) } } @@ -170,11 +171,11 @@ export function createSecretsCache( const value = await secrets.get(key) if (value === undefined) { - log('load missed', key) + log('read failed (key not found)', key) return } - log('load succeeded', key) + log('loaded', key) return value } catch (error) { throw ToolkitError.chain(error, 'Failed to get value from secrets storage', { @@ -193,9 +194,9 @@ export function createSecretsCache( }) } - log('save succeeded', key) + log('saved', key) }, - clear: async key => { + clear: async (key, reason) => { try { await secrets.delete(key) } catch (error) { @@ -205,7 +206,7 @@ export function createSecretsCache( }) } - log('clear succeeded', key) + log(`deleted (reason: ${reason})`, key) }, } } diff --git a/tsconfig.json b/tsconfig.json index 2818170e3c5..d5b53761c57 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ }, "incremental": true, "module": "commonjs", - "target": "es6", + "target": "es2021", "outDir": "dist", "sourceMap": true, "moduleResolution": "node", @@ -16,7 +16,7 @@ "strict": true, "noUnusedLocals": true, "noImplicitOverride": true, - "lib": ["dom", "es6", "esnext.asynciterable"], + "lib": ["dom", "es2021"], "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "jsx": "preserve", diff --git a/webpack.base.config.js b/webpack.base.config.js index 2df0bfa20b7..d22c2b560bf 100644 --- a/webpack.base.config.js +++ b/webpack.base.config.js @@ -69,7 +69,7 @@ const baseConfig = { loader: 'esbuild-loader', options: { loader: 'ts', - target: 'es2018', + target: 'es2021', }, }, ], @@ -94,7 +94,7 @@ const baseConfig = { minimize: true, minimizer: [ new ESBuildMinifyPlugin({ - target: 'es2018', + target: 'es2021', }), ], },