From 7d3c4c3e8a7b3bf505e3115cbf05b8bb7029a7e8 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Wed, 8 Feb 2023 15:55:57 +0800 Subject: [PATCH] Fix rerun button of Actions (#22798) When clicking the return button, the page should be refreshed. However, the browser may cancel the previous fetch request, and it fails to rerun the job. It's easier to reproduce the bug in Safari or Firefox than Chrome for some reason. image image --- web_src/js/components/RepoActionView.vue | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/web_src/js/components/RepoActionView.vue b/web_src/js/components/RepoActionView.vue index 4c7408d1b3..703fe59d81 100644 --- a/web_src/js/components/RepoActionView.vue +++ b/web_src/js/components/RepoActionView.vue @@ -20,7 +20,8 @@ {{ job.name }} - @@ -162,12 +163,14 @@ const sfc = { } }, // rerun a job - rerunJob(idx) { - this.fetch(`${this.run.link}/jobs/${idx}/rerun`); + async rerunJob(idx) { + const jobLink = `${this.run.link}/jobs/${idx}`; + await this.fetchPost(`${jobLink}/rerun`); + window.location.href = jobLink; }, // cancel a run cancelRun() { - this.fetch(`${this.run.link}/cancel`); + this.fetchPost(`${this.run.link}/cancel`); }, createLogLine(line) { @@ -205,7 +208,7 @@ const sfc = { // for example: make cursor=null means the first time to fetch logs, cursor=eof means no more logs, etc return {step: idx, cursor: it.cursor, expanded: it.expanded}; }); - const resp = await this.fetch( + const resp = await this.fetchPost( `${this.actionsURL}/runs/${this.runIndex}/jobs/${this.jobIndex}`, JSON.stringify({logCursors}), ); @@ -245,7 +248,7 @@ const sfc = { } }, - fetch(url, body) { + fetchPost(url, body) { return fetch(url, { method: 'POST', headers: {