Skip to content

Commit cb07bb2

Browse files
authored
Merge #3840 build: set target to "es2021"
2 parents de8244c + 66a72be commit cb07bb2

File tree

8 files changed

+37
-35
lines changed

8 files changed

+37
-35
lines changed

scripts/build/package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import * as fs from 'fs-extra'
2424
import { betaUrl } from '../../src/dev/config'
2525

2626
const packageJsonFile = './package.json'
27-
const webpackConfigJsFile = './webpack.config.js'
27+
const webpackConfigJsFile = './webpack.base.config.js'
2828

2929
function parseArgs() {
3030
// Invoking this script with argument "foo":

src/auth/providers/credentialsProviderManager.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ export class CredentialsProviderManager {
3232
telemetry.aws_loadCredentials.emit({ credentialSourceId: telemType, value: 1 })
3333
providers = providers.concat(provider)
3434
} else {
35-
getLogger().verbose(
36-
`provider for ${provider.getCredentialsId().credentialTypeId} unavailable in this environment`
37-
)
35+
getLogger().verbose('auth: "%s" provider unavailable', provider.getCredentialsId().credentialTypeId)
3836
}
3937
}
4038

src/auth/providers/sharedCredentialsProviderFactory.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,17 @@ export class SharedCredentialsProviderFactory extends BaseCredentialsProviderFac
4747
private async loadSharedCredentialsProviders(): Promise<void> {
4848
this.resetProviders()
4949

50-
this.logger.verbose('Loading all Shared Credentials Sections')
5150
const result = await loadSharedCredentialsSections()
5251
if (result.errors.length > 0) {
5352
const errors = result.errors.map(e => e.message).join('\t\n')
54-
getLogger().verbose(`credentials: errors occurred while parsing:\n%s`, errors)
53+
getLogger().warn(`credentials: errors while parsing:\n%s`, errors)
5554
}
5655

5756
this.loadedCredentialsModificationMillis = await this.getLastModifiedMillis(getCredentialsFilename())
5857
this.loadedConfigModificationMillis = await this.getLastModifiedMillis(getConfigFilename())
5958
await updateAwsSdkLoadConfigEnvVar()
6059

61-
getLogger().verbose(`credentials: found sections: ${result.sections.map(s => `${s.type}:${s.name}`)}`)
60+
getLogger().verbose(`credentials: found sections: ${result.sections.map(s => `${s.type}:${s.name}`).join(' ')}`)
6261
for (const section of result.sections) {
6362
if (section.type === 'profile') {
6463
await this.addProviderIfValid(

src/auth/sso/cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function getRegistrationCache(directory = getCacheDir()): KeyedCache<Clie
4646
const read = (data: StoredRegistration) => ({ ...data, expiresAt: new Date(data.expiresAt) })
4747
const write = (data: ClientRegistration) => ({ ...data, expiresAt: data.expiresAt.toISOString() })
4848

49-
const logger = (message: string) => getLogger().debug(`SSO registration cache: ${message}`)
49+
const logger = (message: string) => getLogger().debug('auth: SSO registration cache: %s', message)
5050
const cache: KeyedCache<StoredRegistration, RegistrationKey> = createDiskCache(
5151
(registrationKey: RegistrationKey) => getRegistrationCacheFile(directory, registrationKey),
5252
logger

src/auth/sso/ssoAccessTokenProvider.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ export class SsoAccessTokenProvider {
7575
) {}
7676

7777
public async invalidate(): Promise<void> {
78-
await Promise.all([
79-
this.cache.token.clear(this.tokenCacheKey),
80-
this.cache.registration.clear(this.registrationCacheKey),
78+
// Use allSettled() instead of all() to ensure all clear() calls are resolved.
79+
await Promise.allSettled([
80+
this.cache.token.clear(this.tokenCacheKey, 'SsoAccessTokenProvider.invalidate()'),
81+
this.cache.registration.clear(this.registrationCacheKey, 'SsoAccessTokenProvider.invalidate()'),
8182
])
8283
}
8384

@@ -114,7 +115,7 @@ export class SsoAccessTokenProvider {
114115
return await this.authorize(registration)
115116
} catch (err) {
116117
if (err instanceof SSOOIDCServiceException && isClientFault(err)) {
117-
await this.cache.registration.clear(cacheKey)
118+
await this.cache.registration.clear(cacheKey, `client fault: SSOOIDCServiceException: ${err.message}`)
118119
}
119120

120121
throw err
@@ -141,7 +142,10 @@ export class SsoAccessTokenProvider {
141142
} as AwsRefreshCredentials)
142143

143144
if (err instanceof SSOOIDCServiceException && isClientFault(err)) {
144-
await this.cache.token.clear(this.tokenCacheKey)
145+
await this.cache.token.clear(
146+
this.tokenCacheKey,
147+
`client fault: SSOOIDCServiceException: ${err.message}`
148+
)
145149
}
146150
}
147151

src/shared/utilities/cacheUtils.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ export interface KeyedCache<T, K = string> {
3333
save(key: K, data: T): Promise<void>
3434

3535
/**
36-
* Removes the data stored at {@link key}, if any.
36+
* Deletes data stored at {@link key}, if any.
3737
*
3838
* @param key Target key to clear.
39+
* @param reason Partial log message explaining why the data is being deleted.
3940
*/
40-
clear(key: K): Promise<void>
41+
clear(key: K, reason: string): Promise<void>
4142
}
4243

4344
/**
@@ -71,7 +72,7 @@ export function mapCache<T, U, K>(cache: KeyedCache<T, K>, get: (data: T) => U,
7172
const getIf = (data?: T) => (data !== undefined ? get(data) : undefined)
7273

7374
return {
74-
clear: key => cache.clear(key),
75+
clear: (key, reason) => cache.clear(key, reason),
7576
load: key => cache.load(key).then(getIf),
7677
save: (key, data) => cache.save(key, set(data)),
7778
}
@@ -91,10 +92,10 @@ export function createDiskCache<T, K>(
9192
mapKey: (key: K) => string,
9293
logger?: (message: string) => void
9394
): KeyedCache<T, K> {
94-
function log(prefix: string, key: K): void {
95+
function log(msg: string, key: K): void {
9596
if (logger) {
9697
const keyMessage = typeof key === 'object' ? JSON.stringify(key) : key
97-
logger(`${prefix} for key '${keyMessage}'`)
98+
logger(`${msg} key: ${keyMessage}`)
9899
}
99100
}
100101

@@ -104,11 +105,11 @@ export function createDiskCache<T, K>(
104105

105106
try {
106107
const result = JSON.parse(await SystemUtilities.readFile(target))
107-
log('load succeeded', key)
108+
log('loaded', key)
108109
return result
109110
} catch (error) {
110111
if (isFileNotFoundError(error)) {
111-
log('load missed', key)
112+
log('read failed (file not found)', key)
112113
return
113114
}
114115

@@ -131,16 +132,16 @@ export function createDiskCache<T, K>(
131132
})
132133
}
133134

134-
log('save succeeded', key)
135+
log('saved', key)
135136
},
136-
clear: async key => {
137+
clear: async (key, reason) => {
137138
const target = mapKey(key)
138139

139140
try {
140141
await SystemUtilities.delete(target)
141142
} catch (error) {
142143
if (isFileNotFoundError(error)) {
143-
return log('clear succeeded, file does not exist', key)
144+
return log('file not found', key)
144145
}
145146

146147
throw ToolkitError.chain(error, `Failed to delete "${target}"`, {
@@ -149,7 +150,7 @@ export function createDiskCache<T, K>(
149150
})
150151
}
151152

152-
log('clear succeeded', key)
153+
log(`deleted (reason: ${reason})`, key)
153154
},
154155
}
155156
}
@@ -158,9 +159,9 @@ export function createSecretsCache(
158159
secrets: vscode.SecretStorage,
159160
logger?: (message: string) => void
160161
): KeyedCache<string> {
161-
function log(prefix: string, key: string): void {
162+
function log(msg: string, key: string): void {
162163
if (logger) {
163-
logger(`${prefix} for key '${key}'`)
164+
logger(`${msg} key: ${key}`)
164165
}
165166
}
166167

@@ -170,11 +171,11 @@ export function createSecretsCache(
170171
const value = await secrets.get(key)
171172

172173
if (value === undefined) {
173-
log('load missed', key)
174+
log('read failed (key not found)', key)
174175
return
175176
}
176177

177-
log('load succeeded', key)
178+
log('loaded', key)
178179
return value
179180
} catch (error) {
180181
throw ToolkitError.chain(error, 'Failed to get value from secrets storage', {
@@ -193,9 +194,9 @@ export function createSecretsCache(
193194
})
194195
}
195196

196-
log('save succeeded', key)
197+
log('saved', key)
197198
},
198-
clear: async key => {
199+
clear: async (key, reason) => {
199200
try {
200201
await secrets.delete(key)
201202
} catch (error) {
@@ -205,7 +206,7 @@ export function createSecretsCache(
205206
})
206207
}
207208

208-
log('clear succeeded', key)
209+
log(`deleted (reason: ${reason})`, key)
209210
},
210211
}
211212
}

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"incremental": true,
99
"module": "commonjs",
10-
"target": "es6",
10+
"target": "es2021",
1111
"outDir": "dist",
1212
"sourceMap": true,
1313
"moduleResolution": "node",
@@ -16,7 +16,7 @@
1616
"strict": true,
1717
"noUnusedLocals": true,
1818
"noImplicitOverride": true,
19-
"lib": ["dom", "es6", "esnext.asynciterable"],
19+
"lib": ["dom", "es2021"],
2020
"skipLibCheck": true,
2121
"forceConsistentCasingInFileNames": true,
2222
"jsx": "preserve",

webpack.base.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const baseConfig = {
6969
loader: 'esbuild-loader',
7070
options: {
7171
loader: 'ts',
72-
target: 'es2018',
72+
target: 'es2021',
7373
},
7474
},
7575
],
@@ -94,7 +94,7 @@ const baseConfig = {
9494
minimize: true,
9595
minimizer: [
9696
new ESBuildMinifyPlugin({
97-
target: 'es2018',
97+
target: 'es2021',
9898
}),
9999
],
100100
},

0 commit comments

Comments
 (0)