Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit fd874c5

Browse files
committed
fix: don't repeatedly use invalid SRC_ACCESS_TOKEN env variable
1 parent 2b20aae commit fd874c5

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/settings/accessTokenSetting.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { endpointSetting } from './endpointSetting'
66
import { readConfiguration } from './readConfiguration'
77

88
let cachedAccessToken: Promise<string> | undefined
9+
const invalidAccessTokens = new Set<string>()
910

1011
export function accessTokenSetting(): Promise<string> {
1112
const fromSettings = readConfiguration().get<string>('accessToken', '')
@@ -14,14 +15,15 @@ export function accessTokenSetting(): Promise<string> {
1415
}
1516

1617
const environmentVariable = process.env.SRC_ACCESS_TOKEN
17-
if (environmentVariable) {
18+
if (environmentVariable && !invalidAccessTokens.has(environmentVariable)) {
1819
return Promise.resolve(environmentVariable)
1920
}
2021

2122
return promptUserForAccessTokenSetting()
2223
}
2324

2425
export async function deleteAccessTokenSetting(tokenValueToDelete: string): Promise<void> {
26+
invalidAccessTokens.add(tokenValueToDelete)
2527
const currentValue = readConfiguration().get<string>('accessToken')
2628
if (currentValue === tokenValueToDelete) {
2729
cachedAccessToken = undefined

0 commit comments

Comments
 (0)