fix(cockpit): a place pack retried after a failure counts as failed only if the retry fails

This commit is contained in:
Sameh Khamis committed 2026-11-08 19:49:05 -08:00
1 parent e954734379
commit f6dc89b4fa
3 files changed
+19 -2

No files matched your search

+3 -1
View File
@@ -64,7 +64,7 @@ function notifyLoading() {
/**
* A pack load that the loading status follows: on its way while it runs,
* failed until a later load of it succeeds.
* failed from a failure until it is tried again.
* @template T
* @param {string} name
* @param {() => Promise<T>} load
@@ -72,6 +72,8 @@ function notifyLoading() {
*/
export function reportedPlacePackLoad(name, load) {
return async () => {
// A retry is a fresh try: its batch ends on what this load does.
failedPacks.delete(name);
loadingPacks.add(name);
notifyLoading();
try {
+7 -1
View File
@@ -32,6 +32,12 @@ test('a pack that would not load stays failed until it loads', async () => {
await assert.rejects(load(), /offline/);
assert.deepEqual(place.placePacksStatus(), { loading: false, failed: true });
fail = false;
assert.equal(await load(), 1);
const retry = load();
assert.deepEqual(
place.placePacksStatus(),
{ loading: true, failed: false },
'a retry is not a failure until it fails',
);
assert.equal(await retry, 1);
assert.deepEqual(place.placePacksStatus(), { loading: false, failed: false });
});