Skip to content

Commit 70318d9

Browse files
committed
Only cache project attributes in case of successful retrieval
1 parent 1724a5d commit 70318d9

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

integration/vscode/ada/src/ExtensionState.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,15 @@ export class ExtensionState {
411411
arguments: [queryArgs],
412412
};
413413

414-
const queryPromise = this.adaClient.sendRequest(
415-
ExecuteCommandRequest.type,
416-
params,
417-
) as Promise<string | string[]>;
418-
419-
this.projectAttributeCache.set(mapKey, queryPromise);
414+
const queryPromise = this.adaClient
415+
.sendRequest(ExecuteCommandRequest.type, params)
416+
.then((value) => {
417+
/**
418+
* Only cache the promise if it was fulfilled.
419+
*/
420+
this.projectAttributeCache.set(mapKey, queryPromise);
421+
return value as string | string[];
422+
});
420423

421424
return queryPromise;
422425
} else {

integration/vscode/ada/src/gnattest.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,15 @@ export async function getHarnessDir() {
171171
/**
172172
* default to gnattest/harness if Harness_Dir is unspecified
173173
*/
174-
() => path.join('gnattest', 'harness'),
174+
(err) => {
175+
if (err instanceof Error && err.message == 'The queried attribute is not known') {
176+
return path.join('gnattest', 'harness');
177+
} else {
178+
// Reject the promise with the same error.
179+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
180+
return Promise.reject(err);
181+
}
182+
},
175183
)
176184
.then(async (value) => path.join(await adaExtState.getObjectDir(), value as string));
177185
}

0 commit comments

Comments
 (0)