@@ -51,7 +51,7 @@ import {
5151 TextInput ,
5252 WorkflowGrid ,
5353} from ' ~components' ;
54- import { getEndTimeIsoString , getStartTimeIsoString } from ' ~helpers' ;
54+ import { delay , getEndTimeIsoString , getStartTimeIsoString } from ' ~helpers' ;
5555import { httpService } from ' ~services' ;
5656
5757export default {
@@ -76,6 +76,7 @@ export default {
7676 ],
7777 data () {
7878 return {
79+ abortController: undefined ,
7980 isCronList: IS_CRON_LIST ,
8081 loading: false ,
8182 results: [],
@@ -207,28 +208,45 @@ export default {
207208 return { workflows, nextPageToken };
208209 }
209210
210- this .loading = true ;
211- this .error = undefined ;
212-
213211 const includeStatus = ! [STATUS_ALL , STATUS_OPEN , STATUS_CLOSED ].includes (
214212 queryWithStatus .status
215213 );
216214 const { status , ... queryWithoutStatus } = queryWithStatus;
217215 const query = includeStatus ? queryWithStatus : queryWithoutStatus;
218216
219217 try {
220- const res = await httpService .get (url, { query });
218+ if (this .abortController ) {
219+ this .abortController .abort ();
220+ await delay ();
221+ }
221222
222- workflows = res .executions ;
223+ this .error = undefined ;
224+ this .loading = true ;
223225
224- nextPageToken = res .nextPageToken ;
225- } catch (e) {
226- this .error = (e .json && e .json .message ) || e .status || e .message ;
227- }
226+ this .abortController = new AbortController ();
227+ const { signal } = this .abortController ;
228228
229- this .loading = false ;
229+ const request = await httpService .get (url, { query, signal });
230+
231+ this .abortController = undefined ;
232+
233+ workflows = request .executions ;
234+
235+ nextPageToken = request .nextPageToken ;
236+ } catch (error) {
237+ if (error .name === ' AbortError' ) {
238+ return { status: ' aborted' };
239+ }
240+
241+ this .error =
242+ (error .json && error .json .message ) || error .status || error .message ;
230243
231- return { workflows, nextPageToken };
244+ return { status: ' error' };
245+ } finally {
246+ this .loading = false ;
247+ }
248+
249+ return { status: ' success' , workflows, nextPageToken };
232250 },
233251 fetchDomain () {
234252 const { domain , now } = this ;
@@ -284,33 +302,50 @@ export default {
284302 query .queryString = decodeURI (query .queryString );
285303 }
286304
287- const { workflows: wfs , nextPageToken } = await this .fetch (
305+ const { status , workflows: wfs , nextPageToken } = await this .fetch (
288306 this .fetchWorkflowListUrl ,
289307 query
290308 );
291309
310+ if (status !== ' success' ) {
311+ return ;
312+ }
313+
292314 workflows = wfs;
293315 this .npt = nextPageToken;
294316 } else {
295317 const { domain } = this ;
296318 const queryOpen = { ... this .criteria , nextPageToken: this .npt };
297319 const queryClosed = { ... this .criteria , nextPageToken: this .nptAlt };
298320
299- const { workflows: wfsOpen , nextPageToken: nptOpen } = await this .fetch (
321+ const {
322+ status: openStatus ,
323+ workflows: wfsOpen ,
324+ nextPageToken: nptOpen ,
325+ } = await this .fetch (
300326 ` /api/domains/${ domain} /workflows/open` ,
301327 queryOpen
302328 );
303329
330+ if (openStatus !== ' success' ) {
331+ return ;
332+ }
333+
304334 this .npt = nptOpen;
305335
306336 const {
337+ status: closedStatus ,
307338 workflows: wfsClosed ,
308339 nextPageToken: nptClosed ,
309340 } = await this .fetch (
310341 ` /api/domains/${ domain} /workflows/closed` ,
311342 queryClosed
312343 );
313344
345+ if (closedStatus !== ' success' ) {
346+ return ;
347+ }
348+
314349 this .nptAlt = nptClosed;
315350
316351 workflows = [... wfsOpen, ... wfsClosed];
0 commit comments