Skip to content

Commit

Permalink
Ensure task expiration has precedence over any other state
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Jul 16, 2024
1 parent a87408b commit 0eb7eee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ describe("PersistentTaskProgressMonitorAlert.vue", () => {
expect(completedAlert.text()).not.toContain("Download here");
});

it("should render a warning alert when the task has expired", () => {
it("should render a warning alert when the task has expired even if the status is running", () => {
const useMonitor = {
...FAKE_MONITOR,
isRunning: ref(true),
};
const existingMonitoringData: MonitoringData = {
taskId: "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ function dismissAlert() {

<template>
<div v-if="hasMonitoringData" class="d-flex justify-content-end">
<BAlert v-if="isRunning" variant="info" show>
<BAlert v-if="hasExpired" variant="warning" show dismissible @dismissed="dismissAlert">
The {{ monitorRequest.action }} task has <b>expired</b> and the result is no longer available.
</BAlert>
<BAlert v-else-if="isRunning" variant="info" show>
<b>{{ inProgressMessage }}</b>
<FontAwesomeIcon :icon="faSpinner" class="mr-2" spin />
</BAlert>
<BAlert v-else-if="hasExpired" variant="warning" show dismissible @dismissed="dismissAlert">
The {{ monitorRequest.action }} task has <b>expired</b> and the result is no longer available.
</BAlert>
<BAlert v-else-if="isCompleted" variant="success" show dismissible @dismissed="dismissAlert">
<span>{{ completedMessage }}</span>
<BLink v-if="downloadUrl" class="download-link" :href="downloadUrl">
Expand Down
6 changes: 6 additions & 0 deletions client/src/composables/persistentProgressMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ export function usePersistentProgressTaskMonitor(
return loadStatus(currentMonitoringData.value.status!);
}

if (hasExpired.value) {
// The monitoring data has expired. Requesting the status again will likely
// return incorrect results. Reset the monitoring data to start fresh.
return;
}

return waitForTask(currentMonitoringData.value.taskId);
}

Expand Down

0 comments on commit 0eb7eee

Please sign in to comment.